Rich Dougherty rd.nz

Branching and unbranching in Git

I wanted to create a temporary branch for a piece of work.

# Make some changes...

# Oops, need a new branch!
git branch mybranch
git checkout mybranch
git commit

# Make and commit more changes...

# Send branch changes to remote repo.
git push origin mybranch

# All done, time to merge back.
git checkout master
git pull --rebase origin master
git merge mybranch
git commit -a
git push origin

# Remove branch locally and on remote repo.
git branch -d mybranch
git push origin :mybranch