Information Technology Reference
In-Depth Information
You have just created a new revision only to find out that it should go to a different
branch. If your modifications do not collide while switching branche syou can easily
forget to check out the appropriate branch before you commit. After creating the revi-
sion in the wrong branch you want to move it to its correct destination.
Solution
Clone the repository created in Recipe 5-1:
$ cd git-recipes
$ git clone-with-branches 05-01 05-08
$ cd 05-08
and modify the m1.txt file
$ echo A new text > m1.txt
Let's suppose you intended this change to be committed in the master branch. The
modification doesn't collide with the doc branch. You can checkout the doc branch
without any problems using: $ git checkout doc . The checkout command out-
puts a line that give you information about the changes:
M
m1.txt
But it can be easily overlooked.
After some time, you are completely unaware that the current branch is not the
master . You create the wrong revision with:
$ git snapshot Recipe 5-8: a revision in a wrong branch
Now that you realized your failure, you want to move the revision to the master
branch.
You can do it in two separate steps:
• Copy the revision from wrong branch to correct one.
• Remove the revision from wrong branch.
Search WWH ::




Custom Search