Skip to content

Instantly share code, notes, and snippets.

@davidcotter
Created May 24, 2009 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidcotter/117135 to your computer and use it in GitHub Desktop.
Save davidcotter/117135 to your computer and use it in GitHub Desktop.
# Git branching notes
#Local Branching
git branch #show branches and which one you are currently on
git push #push any local changes to the remote repo
git branch david #create a local branch
git checkout david #switch to that branch
Remote Branching
Working on david branch and going home so want to check in to repo but not to master:
git push origin david # push local branch to the remote
git checkout master # switch away from david branch so the next command will execute
git branch -f david origin/david # Local david tracking remote - so push/pull will use it by default (not master)
On other computer
git branch --track local_branch remote_branch
Merging
Finished working on david branch want to merge
git rebase master # merge all changes from master to david (rebase and merge are slightly different)
git pull # make sure checges on remote david branch are also local
git checkout master # switch to master
git diff master david # see changes
git merge david # merge changes
Delete the working branch
git branch -d david #delete the local branch
git push origin :heads/david #delete the remote branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment