Create a remote repo named origin pointing at your Github repo (after you’ve already created the repo on Github) (used if you git init since the repo you created locally isn’t linked to a remote repo yet)
Get a remote branch from origin into a local branch (naming the branch and switching to it)
git push origin –delete (branch_name)
Delete a branch locally and remotely
Integrating Branches merge/rebase
git checkout master git merge (branch_name)
Merge a specific branch into the master branch.
git rebase (branch_name)
Take all the changes in one branch and replay them on another. Usually used in a feature branch. Rebase the master to the feature branch so you are testing your feature on the latest main code base. Then merge to the master.
git cherry-pick (commit_id)
Merge just one specific commit from another branch to your current branch.
Merging: Merging will occur FROM the branch you name TO the branch you are currently in. Rebasing: Usually switch to a feature branch (git checkout newFeature). Then rebase (git rebase master). Then merge back so you have all the changes of master and the feature branch (git checkout master, and git merge newFeature).
There you go! Hopefully that covers most of the basic ones and a few more. If you’d like to see any that haven’t been covered here, I’d be happy to add them. Also if you need a further explanation or demonstration, don’t be scared to ask. Happy gitting!
Cheat Sheet as a Chrome Extension
Interested in having this cheat sheet available in your Chrome browser for easy access? themergency has created this great Chrome extension!