Ken Frederick


Useful Git Commands

While working on the Trivia Knight app, one of the many things I needed to learn was (and still is) Git and using Git for version control. I think I have my head wrapped around the basics of version control now – but while working on projects now, I find myself referring to a list of common Git commands. I’m putting them here in case anyone finds them useful!

New branch:
Create new branch: git checkout -b name-of-branch
git push -u origin name-of-branch

Switch branch:
git checkout name-of-branch (for example, develop)

Merge branch to master:
git checkout master
git merge name-of-branch(for example, develop)

Delete branch:
git branch -d localBranchName
git push origin --delete remoteBranchName

See all branches:
git branch -a