Created
May 9, 2014 18:59
-
-
Save Miista/0ee0dcde3dd03e6bd789 to your computer and use it in GitHub Desktop.
Tips for using "git rebase --interactive"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If the commit you want to fix isn’t the most recent one: | |
git rebase --interactive $parent_of_flawed_commit | |
If you want to fix several flawed commits, pass the parent of the oldest one of them. | |
An editor will come up, with a list of all commits since the one you gave. | |
Change pick to reword (or on old versions of Git, to edit) in front of any commits you want to fix. | |
Once you save, Git will replay the listed commits. | |
For each commit you want to reword, Git will drop you back into your editor. For each commit you want to edit, Git drops you into the shell. If you’re in the shell: | |
Change the commit in any way you like. | |
git commit --amend | |
git rebase --continue | |
Most of this sequence will be explained to you by the output of the various commands as you go. It’s very easy, you don’t need to memorise it – just remember that git rebase --interactive lets you correct commits no matter how long ago they were. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What do I put in $parent_of_flawed_commit?