Information Technology Reference
In-Depth Information
When you start working with branches it is worth remembering that the operation of
switching branches is stored in a reflog. The commands:
$ git checkout doc
$ git checkout master
would result in the following output of $ git reflog entries:
23d9855 HEAD@{0}: checkout: moving from master to doc
7c9bc41 HEAD@{1}: checkout: moving from info to master
The $ git pack-refs --all command packs all the references stored in
.git/refs/heads and stores them in the .git/packed-refs file. You can un-
pack each branch by creating new commits in it.
5-2. Cloning a repository with branches
Problem
You want to create the exact copy of the repository created in Recipe 5-1. You expect
the copy to contain all the branches stored in the original repository: master , doc ,
and info . You also want to create two new branches named foo and bar —they
should point to the same revision as master branch.
You will have to deal with difficulties caused by the behavior of the $ git
clone command: the cloned repository contains only one local branch named mas-
ter . During cloning git only creates one local branch for a branch that is stored in .git/
HEAD in an original repository.
Solution
Clone the repository created in Recipe 5-1 using the following commands:
$ cd git-recipes
$ git clone 05-01 05-02
$ cd 05-02
Search WWH ::




Custom Search