Skip to content

Instantly share code, notes, and snippets.

@MVesuviusC
Created April 19, 2022 13:16
Show Gist options
  • Save MVesuviusC/274939b206b318b8840d7fa07732f1c2 to your computer and use it in GitHub Desktop.
Save MVesuviusC/274939b206b318b8840d7fa07732f1c2 to your computer and use it in GitHub Desktop.
changing git history
If you have any other choice whatsoever, just don't....
git changing history
# View file size in commits
git ls-tree -r --long c433c76cc37621189d349595adb758d54769142e
# update first commit
git rebase -i --root
# Or go to a commit and update it - note the hat ^
git rebase --interactive '64410acc887333691d265d854d6d5a3d18ff7858^'
# in vi, change word next to the commit you want to edit to "edit"
# exit vi - esc, esc, esc, colon, wq (or qa! for no edits)
# After changes are made, re-do the commit
git commit --amend --no-edit
# Go back to head
git rebase --continue
# pray for no conflicts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment