Skip to content

Instantly share code, notes, and snippets.

@pcejrowski
Created October 16, 2017 09:29
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 pcejrowski/8aed3cb839904f8df9e3f73c30cf50d2 to your computer and use it in GitHub Desktop.
Save pcejrowski/8aed3cb839904f8df9e3f73c30cf50d2 to your computer and use it in GitHub Desktop.
Git ammending old commits
#!/bin/bash
# Usage:
# ./git_ammend_old.sh <commit-sha>
# then we change pick to edit for this commit in interactive mode
set -evx
git stash && \
echo "REMEBER TO CHANGE THE COMMIT TO EDIT" && \
git rebase --interactive "${1}^" && \
git stash pop && \
git commit --all --amend --no-edit && \
git rebase --continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment