Information Technology Reference
In-Depth Information
Solution
Clone the repository created in Recipe 5-1 with all the branches:
$ cd git-recipes
$ git clone-with-branches 05-01 05-06
$ cd 05-06
The repository is now clean and contains three branches. You currently are on the
master
branch. Change your current branch to
info
with:
$ git checkout info
and then modify the working directory with the following commands:
$ echo bar > bar.txt
$ echo foo > m1.txt
$ rm m2.txt
$ mv m3.txt new-m3.txt
The file
bar.txt
was created—it is a new untracked file. The
m1.txt
file was
modified—it now contains
foo
instead of
m1
. The next file—
i1.txt
—was deleted.
The last file—
m3.txt
—was renamed to
new-m3.txt
. The command
$ git
status -sb
now prints:
## info
M m1.txt
D m2.txt
D m3.txt
?? bar.txt
?? new-m3.txt
The above changes are not staged, of course. The repository is dirty, and you are in
the
info
branch.
Suppose that you forgot about your changes and for some reason want to checkout
the
doc
branch. The command:
$ git checkout doc