Information Technology Reference
In-Depth Information
• Local tracking branches
• Remote tracking branches 1
All of the branch categories, which may be unclear at the beginning, will become
apparent in chapter 10 during the discussion of remote repositories and collaboration.
They are introduced here to provide a clear point of view right from the beginning. The
subject of cloning with respect to branches will return in the last recipe. There, we con-
sider operating on branches in bare repositories. The recipe will be rarely used, but it
further clarifies the process of switching branches in non-bare repositories.
Once again, do not work in a detached HEAD state. This is pointless, especially
once you understand branching. Remember, using branches guarantees that your revi-
sions will never be lost.
To get the complete picture of branches I will also show how switching
branches—when performed incautiously—can complicate your life. You can recover
from these problems using three simple recipes:
• Clear and reset a branch
• Switch a branch avoiding conflicts
• Recover from inadvertent commits
With these three simple recipes you will be able to take advantage of branching as
soon as you finish reading this chapter. These are emergency recipes—you can apply
them when you're in trouble.
Once in a while you will face the problem of accessing files from different branches.
Two simple commands come to rescue: you can either check out the file from a differ-
ent branch or display it on standard output. The latter solution used with a stream redir-
ector > allows you to rename a file checked out from a different branch. The recipe
presenting these commands underlines the problems you may encounter while working
in heterogeneous environments.
The final part of the chapter presents the recipes that explain how to delete and re-
name branches. This leads us to the very important concepts of merged and not merged
branches.
5-1. Creating and switching branches
Problem
 
Search WWH ::




Custom Search