Information Technology Reference
In-Depth Information
Using the
$ ls
command you can verify that the working directory doesn't contain
the files
x.txt
and
y.txt
. Thus the
foo-bar
branch was successfully reverted.
The history of your project moved forward. Revision
d
was created after the revert
command. Now you want to remerge
foo-bar
branch into the master branch again.
To do this, run the following commands:
$ git format-patch foo-bar
∼
2..foo-bar
$ git checkout -b foo-bar-tmp
$ git am *.patch
$ rm *.patch
$ git branch -M foo-bar-tmp foo-bar
$ git checkout master
$ git merge --no-ff -m "2nd merge of 'foo-bar'" foo-bar
The repository should look like
Figure 8-14(b)
. You can verify this with the
$ git
log --graph --oneline --all --decorate
command. The working dir-
ectory contains the files
x.txt
and
y.txt
.
How It Works
When your repository looks like the one in
Figure 8-14(a)
then the command:
$ git rebase master foo-bar
will not perform a rebase operation. It will just fast-forward a foo-bar branch to the
revision pointed by master branch. If you want to force rebasing you will have to do it
manually with the
$ git format-patch
and
$ git am
commands.
The revisions in the foo-bar branch are available with a range specifier
foo-
bar
∼
2..foo-bar
. The command:
$ git log --oneline foo-bar
∼
2..foo-bar
lists two revisions
x
and
y
. To create the patches for these revisions we use:
$ git format-patch foo-bar
∼
2..foo-bar
Next we create a new temporary branch named foo-bar-tmp: