Skip to content

Instantly share code, notes, and snippets.

@stuartelimu
Last active February 11, 2021 05:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stuartelimu/1bf85a339e88860286af7c6e91d4bd63 to your computer and use it in GitHub Desktop.
Save stuartelimu/1bf85a339e88860286af7c6e91d4bd63 to your computer and use it in GitHub Desktop.
Git Cheatsheet

Undo git add

You can undo git add before commit with

git reset <file>

You can use

git reset

without any file name to unstage all due changes. This can come in handy when there are too many files to be listed one by one in a reasonable amount of time.

check this article

Revert to the last commit

To undo the most recent commit I do this:

First:

git log

get the very latest SHA id to undo.

git revert SHA

That will create a new commit that does the exact opposite of your commit. Then you can push this new commit to bring your app to the state it was before, and your git history will show these changes accordingly.

Check this answer on stack overflow

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