Skip to content

Instantly share code, notes, and snippets.

@sharvit
Created February 21, 2018 08:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sharvit/29bea19847a247075db69d32200c61b9 to your computer and use it in GitHub Desktop.
Save sharvit/29bea19847a247075db69d32200c61b9 to your computer and use it in GitHub Desktop.
Git commands

Cancel 1 last commit, and keep the changes:

git reset HEAD~1

Can replace the number 1 to cancel more than one commit at once:

git reset HEAD~5

Can cancel the commit and remove the changes (dangerous) :

git reset HEAD~1 --hard

Add files to your previous commit:

git add .
git commit --amend --no-edit

Edit your previous commit message:

git commit --amend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment