GIT cheatsheet

This is one of the cheetsheets I have at this website. The primary purpose of this one is to collect all usefull commands you might need in your daily work. It is worth to note that current changes are being applied to local git repo and need to be published to remote.

I will publish it as is and will extend with additional notes as I have more examples.

Reset not commited changes

git reset --hard

Reset changes in the selected file:

git checkout -- file

Get commit history

git log --oneline

Get commit history for the specified file:

git log --follow -- **filename**

Revert to the previous sate (commit sha)

find the commit sha from the previous command:

git checkout **COMMIT_SHA**

alternative way to roll back to the previous commit:

git reset **COMMIT_SHA**

In this case all the files will remain modified. So you nedd to reset the changes and force push to remote:

git reset --hard
git push -ff

Tags:

Categories:

Updated: