diff --git a/Interactive-Rebasing.md b/Interactive-Rebasing.md new file mode 100644 index 0000000..8636425 --- /dev/null +++ b/Interactive-Rebasing.md @@ -0,0 +1,204 @@ +## The Use Case + +Let's start with a simple use case: you want to add a new file to an old commit (with an id of ef1b2b5). + +## The Git Approach: + +### Step 1 + +obtain the id of the commit and begin an interactive rebase like so: +``` +git rebase --interactive ef1b2b5^ +``` +The `^` at the end of the commit is to say that you actually want the base of the rebase to be the _parent_ of ef1b2b5, because the base of the rebase itself can't be edited. + +This command will bring up a todo file in your editor that describes what the rebase intends on doing: +``` +pick ef1b2b5 README: append info about logs in Docker to FAQ section +pick 817fb53 ci: gox, vendor and you +pick ef1f0e0 blah +pick 29b1b27 blah blah + +# Rebase dc8a624..29b1b27 onto dc8a624 (4 commands) +# +# Commands: +# p, pick = use commit +# r, reword = use commit, but edit the commit message +# e, edit = use commit, but stop for amending +# s, squash = use commit, but meld into previous commit +# f, fixup = like "squash", but discard this commit's log message +# x, exec = run command (the rest of the line) using shell +# b, break = stop here (continue rebase later with 'git rebase --continue') +# d, drop = remove commit +# l, label