Useful git commands

Here are some Git commands I frequently use, together with a short explanation.

Also, I don’t like to type long commands but I don’t mind fancy results. No problem, aliases to the rescue!

And last (but not least) is a list of some fine Git resources.

Git reset

Reset uncommited changes and go back to HEAD. It discards all uncommitted changes! Be careful, potentially dangerous, this throws away all your uncommitted changes!

git reset --hard HEAD

Git commit (amend)

If you forgot some changes in your last commit you can still fix this without creating a new commit. Just add your changes and redo the last commit with the amend parameter, it will replace the last commit.

git commit --amend

Watch out if you’ve already pushed to a remote repository, you might need to do a git push -f so be careful, this might mess with other people’s repository.

Colored log tree view

A cool command to view the Git log. Great because it uses color and displays branches in a tree format.