Information Technology Reference
In-Depth Information
$ cd 08-04
$ echo a > a.txt
$ git add -A
$ git commit -m a
$ echo b > b.txt
$ echo c > c.txt
$ echo d > d.txt
$ git add -A
$ git commit -m b
Verify that the repository contains two revisions with the
$ git log --
oneline
command and that the last revision really contains three files. The output of
the
$ git show --name-only
command will print three filenames:
b.txt
,
c.txt
, and
d.txt
.
Now, reset your history to revision
a
, preserving the modifications introduced by re-
vision
b
in the working directory as the new uncommitted change. You can do this with
the
$ git reset HEAD
∼
command. After this command the state of your reposit-
ory returned by
$ git status -sb
will be the following:
?? b.txt
?? c.txt
?? d.txt
As you can see the files are now untracked. You can create three different revisions
with:
$ git add b.txt
$ git commit -m b
$ git add c.txt
$ git commit -m c
$ git add d.txt
$ git commit -m d
The recipe is finished. You can check that the history contains four revisions
a
,
b
,
c
,
and
d
with the
$ git log
command. Every revision contains a single file. To verify
it use the following commands: