Skip to content

Git & Github

Ian Arsenault edited this page Mar 29, 2018 · 2 revisions

Documentation on how to handle branches, pull requests, code reviews along with git commands

Git

Clone a repository

$ git clone https://github.com/LynxMasters/base.git

Make your own work branch follow this naming convention

$ git checkout -b "ian/facebook-api-calls"

After you're done with your work follow these steps

$ git status  # displays state of working directory 
$ git add <filename> # to add individual files
# or 
$ git add . # adds all files in working directory

Next commit the changes you've made to your local branch

$ git commit -m "added new fetch call to pull profile friends" 

Now lets make sure there haven't been any updates to Master branch

$ git checkout master # this switches you back to master branch
$ git fetch # this will fetch any changes from master
# If there are changes you should get a message along these lines
On branch Master
Your branch is behind 'origin/master' by 2 commits
Use "git pull" to update your local branch
$ git pull # pull any changes made since last fetch/merge

It should display all files that have been changes since last pull

Now lets checkout your working branch and merge the changes you just pulled

$ git checkout -b "ian/facebook-api-calls"  # checkout your work branch
$ git merge master # this will merge your work branch with master

If you have any merge conflicts resolve them See How here

Next push your changes to it's own remote branch

$ git push --set-upstream origin ian/facebook-api-calls # this creates a remote branch on github

Other Techniques


Use git stash and git stash pop

Check status of your working branch

$ git status

If you have untracked files that need to be commit but want to pull changes from master

$ git stash # this will stash your untracked files and revert HEAD commit
# run 'git status' to see your local changes are stashed away

**Checkout master and pull any changes **

$ git checkout master
$ git pull
$ git checkout <name/your-branch>

Re-applying your stashed changes

$ git stash pop # this will reapply stashed changes to local directory
$ git status # you will now see your changes
$ git add .
$ git push

Github

TODO

Clone this wiki locally