Git commands I use all the time for dealing with branches.

This isn’t anything new, but I use these all the time so it’s nice to have something to point to for git newcomers.

# create a new branch and check it out
git checkout -b BRANCH
# list all branches—you should prune regularly to keep the list small
git branch
# delete a local branch that’s been merged in—it’ll complain if it has changes not merged into your current branch
git branch -d BRANCH
# after deleting locally, delete remotely
git push origin :BRANCH
# Let’s say I committed to master, but haven’t pushed to github
# and I realize the commit should be on a branch (to make a pull request from)
git checkout -b BRANCH
git checkout master
git reset head^ –hard # This will wipe out your last commit, so don’t do this before checking that the commit is indeed on another branch



Similar Articles

The World's Most Powerful Mobile Data Collection Platform

Start a FREE 30-day CommCare trial today. No credit card required.

Get Started

Learn More

Get the latest news delivered
straight to your inbox