Information Technology Reference
In-Depth Information
At the very beginning of the branching tour it is easier to switch branches in a clear
state. That is not compulsory, however. Once you practiced the basics, you will need to
switch to a branch while keeping the repository dirty. I've dissected this task into two
separate recipes: unconflicted and conflicted case. The unconflicted case can result in
committing in a wrong branch. This problem is addressed by cherry-picking and reset
commands. Conflicted case of branch switching is a perfect place to introduce stash-
ing—a method of storing your dirty state.
The next aspect of branching is related to bare and non-bare classification. While
learning to switch branches in bare repositories, we dissected the same operation in
non-bare repositories into a symbolic reference update and a reset of the working dir-
ectory. It gave you a deeper insight into some commands, such as checkout. They oper-
ate on the working directory and thus cannot be executed in bare repositories.
Finally, you learned new methods to identify revisions:
• Symbolic reference HEAD
• Branch names
• Ancestor references
• Stash references
The ancestor references can be used together with all other methods, as in:
HEAD
master 2
stash@{4} 5
And remember, do not use the detached HEAD state to commit your work. Always
use branches for that.
1 Y es, these are local branches, as well. They are local branches that track remote branches. 2 The
name of the branch can be different—it is the name of the current branch in the remote reposit-
ory. That's why Recipe 5-1 was finished with $ git checkout master . It guarantees that
after cloning, repository 05-02 will contain the master branch. 3 T he path to the file can be differ-
ent on your system. On CentOS, for example, it is /usr/libexec/git-core. 4 F iles are stored in git
database as binary large objects (blobs).
 
 
 
Search WWH ::




Custom Search