Skip to content

Instantly share code, notes, and snippets.

@gbpereira
Last active March 2, 2018 13:06
Show Gist options
  • Save gbpereira/0404f5f5b7d19235faf339d1c8b1a4e3 to your computer and use it in GitHub Desktop.
Save gbpereira/0404f5f5b7d19235faf339d1c8b1a4e3 to your computer and use it in GitHub Desktop.
git commands to undo changes

Reverting batch commits

git checkout -b <new_branch> <ref_branch>
git reset <previous_commit_hash>
git add -p
git clean -f
git reset --hard

Amending commit with open Pull request

git add -A
git commit --amend
git push <remote> -f <branch>

Converting batch commits into one -> Merge all the commits into the first one

git reset <first_commit_hash>
git add -p
git commit --amend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment