Here are all the Git commands I used last week, and what they do.
Sam Corcos
1.94K41

A few more :)

Very informative, thanks!

There are a few commands that are quite useful, and not listed here.

Let’s start with

git fetch

It fetches the current state from your remote repo (origin by default). You don’t need to pull remote changes before viewing your current state.

Also, let’s not forget about deleting branches. In order to keep your repo nice and clean, after you’ve developed your awesome feature, you need to merge it back into master.

git checkout master
git merge my-awesome-feature

After merging, you don’t need your my-awesome-feature branch anymore, so you can safely delete it:

git branch -d my-awesome-feature

Note that this will not succeed if there are any commits on the deleted branch that have not yet been merged (which is a good thing). If you’re absolutely sure that you want to delete a branch that has unmerged commits, use the -D flag.

After deleting the branch, you don’t need it in your remote repo either, so simply run

git push origin :my-awesome-feature

to delete it from the remote repo as well.