Information Technology Reference
In-Depth Information
How It Works
The interactive rebasing is implemented as an iteration that loops through the com-
mands shown in
Listing 8-10
.
This iteration is performed in a detached HEAD state.
When you close the editor containing the subcommands shown in
Listing 8-10
git
enters detached a HEAD state and performs the iteration.
applies the patch defined by the revision
x
identified with
9aa7b18
and then the re-
basing is paused. You are left in a detached HEAD state right after the patch
x
. If you
want to verify, this run the command
$ git status -sb
. You will see the follow-
ing output:
## HEAD (no branch)
It proves that you are now working in a detached HEAD state. The bash command
prompt:
gajdaw@GAJDAW
/c/git-recipes/08-07 (master|REBASE-i 1/3)
prints the information that you are performing a rebase operation with three patches
and that the first patch was applied.
As you know, git allows you to work in a detached HEAD state with commands
such as
$ git add
and
$ git commit
. Thus you can create a new file with
$
echo y > y.txt
, stage it with
$ git add y.txt
, and finally amend the cur-
rent commit with
$ git commit --amend --no-edit
. That's how the
x
com-
mit gets modified. If you skip the
--no-edit
option, then git will fire the editor and
you will get the chance to modify the comment for revision
x
'.
Once you finish with the
x
commit you can proceed with creating revision
z
. When
this is finished you finalize the recipe with the
$ git rebase --continue
com-
mand.
It's worth noting that when interactive rebasing is paused you may modify the his-
tory with other methods. You can insert additional commits with
$ git commit
or
you can remove some commits with
$ git reset
. However, you cannot perform
another interactive rebasing until you finish the first one.
You can abort paused rebasing with
$ git rebase --abort
. To undo the op-
eration use reflog.