rocarvaj
1/18/2014 - 11:04 PM

Git branching

Git branching

Git cheat sheet: Stuff I always forget

See: http://documentup.com/skwp/git-workflows-book#

  1. Create branch

  2. Commit a temp "bookmark":

git commit -a -m "uncommit me: need to finish stuff in the user model"

  1. Then uncommit:

git reset --soft HEAD^

  1. Push to remote:

git push origin <branch-name>

  1. If I'm working from another machine:

git checkout -t -b <branch-name> origin/<branch-name>

  1. Merge branch into master:

git checkout master

git merge <branch-name>

  1. Delete local branch:

git branch -D <branch-name>

  1. Delete remote branch:

git push origin :<branch-name> or git push origin --delete <branch-name>

  1. Change remote branch that a branch is tracking

Without deleting anything, using git up to v1.7.12:

git branch --set-upstream branch_name your_new_remote/branch_name

Using git v1.8.0 or later:

git branch branch_name --set-upstream-to your_new_remote/branch_name

Create branch

git checkout -b <branch-name>