Skip to content

Instantly share code, notes, and snippets.

@christiangalsterer
Created February 28, 2018 16:37
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 christiangalsterer/cccaa20bd1bc4a39d14bb013ef282e31 to your computer and use it in GitHub Desktop.
Save christiangalsterer/cccaa20bd1bc4a39d14bb013ef282e31 to your computer and use it in GitHub Desktop.

Undo last n commits. After running the command, you'll find the changes as uncommitted local modifications in your working copy.

git reset --soft HEAD~1

Undo last n commits. After running the command, the last changes are not longer available.

$ git reset --hard HEAD~1

Update file permissions on file(s), here add execution permissions on all sh files in the current directory

git update-index --chmod=+x *.sh

Revert merge commit to a previous state

To find the merge commit to revert

git log 
  • -m 1 is the first parent, i.e. the commit where merge was merged into
  • -n doesn't commit automatically
git revert -m 1 -n <merge-commit>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment