Information Technology Reference
In-Depth Information
$ cd git-recipes
$ git clone-with-branches 05-01 05-11
$ cd 05-11
You are in the
master
branch. Change the name of the
info
branch to
inform-
ation
with:
$ git branch -m info information
Finally, change the name of the
master
branch to
doc
with:
$ git branch -M master doc
How It Works
The command
$ git branch -m [old-name] [new-name]
renames the
branch named
old-name
to
new-name
. If the branch with a new name already ex-
ists, then you can overwrite it using
$ git branch -M [old-name] [new-
name]
. In this case the existing
new-name
branch will be lost.
By the way, did you notice? The
master
branch can be renamed and re-
moved—just as any other branch.
5-12. Checking out a file from a different
branch
Problem
While working on a project with many branches, you have just realized that while on
one branch you need some files from another branch. You want to checkout files from
a branch that is not your current branch.
Solution
Clone the repository created in Recipe 5-1 with: