Information Technology Reference
In-Depth Information
Before you proceed with the procedures given below verify that the new revision is
present in
doc
branch and absent from
master
branch. Here are the commands you
need:
$ git log --oneline doc
$ git log --oneline master
Here is the procedure you need to copy the latest revision from the
doc
branch to
the
master
branch:
1. Change the current branch to
master
with the
$ git checkout
master
command.
2. Copy the tip revision from the
doc
branch to your current branch (which
is the
master
) with the
$ git cherry-pick doc
command.
As of now, the new revision is present in both branches. The commands
$ git
log --oneline -1 master
and
$ git log --oneline -1 doc
print the
output shown in
Listing 5-3
. Although your actual hashes will be different, you should
notice that the two SHA-1 names of your commits are different.
Listing 5-3.
The output of $ git log --oneline -1 for the two branches
# the output of $ git log --oneline -1 master
43336a3 Recipe 5-8: a revision in a wrong branch
# the output of $ git log --oneline -1 doc
7ad4187 Recipe 5-8: a revision in a wrong branch
Finish the recipe removing the erroneous revision from the
doc
branch:
1. Change the current branch to
doc
with the
$ git checkout doc
command.
2. Remove the revision with the
$ git reset --hard HEAD
∼
com-
mand.
The output of
$ git l master
and
$ git l doc
proves that the new revi-
sion is included only in the
master
branch. You also can verify it with one command