# Github bootcamp --- ### Git motivation - Time travel - Self-confidence - Command work (automerging) --- ### Basic commands You can use IDE ``` git init ``` ``` git add -A git commit -m 'Added new model' ``` ``` git checkout d3d127 ``` --- ### Working tree vs staging area ![](https://i.imgur.com/kKzLgoL.png) --- ### Branching ![](https://i.imgur.com/8VhTSBH.jpg =400x) --- ### Branching 2 Create branch ``` git checkout -b prior_networks ``` Switch to existent branch ``` git checkout master ``` Merging ``` git merge prior_networks ``` ![](https://i.imgur.com/9iIkdU6.jpg =400x) --- #### Remote repo local <-> github ``` git push -u origin prior_networks ``` ``` git checkout master git pull ``` --- ### Could we just push to master? --- ### Pull requests 1. Write code locally in feature_branch 2. Push to remote feature_branch 3. Make pull request ![](https://i.imgur.com/ujUHh5k.png) --- ### But in reality... 01. Checkout locally to master & `git pull` 02. Checkout locally to feature_branch & `git merge master` 1. Write code locally in feature_branch 2. Push to remote feature_branch 3. Make pull request --- ### Clean the room .gitignore ``` *.pyc *.ipynb_checkpoints data/* ``` clean the notebook outputs (by hand or with https://github.com/kynan/nbstripout hook) --- Advanced commands ``` git diff git diff HEAD HEAD~3 ``` ``` git stash ... git stash apply ``` ``` git blame main.py ``` ``` git commit --amend ``` --- ### Homework 1. Create own repo 2. Create two parallel branches to master (with commits in each) and merge them 3. Create some file with code; watch diff; add the file to the working tree - watch diff again. 4. Make a PR to alpaca with random name and random code
{"metaMigratedAt":"2023-06-15T10:22:06.704Z","metaMigratedFrom":"YAML","title":"Github usage","breaks":true,"slideOptions":"{\"theme\":\"beige\",\"transition\":\"fade\"}","contributors":"[{\"id\":\"173eb66f-920d-45e9-8ef5-4b365abfa9d8\",\"add\":2185,\"del\":244}]"}
    269 views