Information Technology Reference
In-Depth Information
$ git reset --hard HEAD@{1}
After this, the repository contains three files
lorem.txt
,
ipsum.txt
, and
dol-
Listing 3-12.
The output of a git reflog after a git reset --hard HEAD@{1}
481f34f HEAD@{0}: reset: moving to HEAD@{1}
aae6588 HEAD@{1}: reset: moving to HEAD@{2}
481f34f HEAD@{2}: commit: dolor
84fb524 HEAD@{3}: commit: ipsum
aae6588 HEAD@{4}: commit (initial): lorem
How It Works
Git reflog is a special log that stores the information about your movements in the re-
pository. Each time you create a revision, reset the repository, or otherwise change the
current revision, the reflog is updated. The name
HEAD@{0}
always points to the cur-
rent revision. A previous revision is available as
HEAD@{1}
. The revision that was
current two operations ago is available as
HEAD@{2}
, and so on. Thus, you can al-
ways refer to previous revisions, even if you don't know their names.
3-9. Creating a new repository in an ex-
isting project
Problem
You work on a project that already consists of a large number of files and directories.
You want to start using git for that project.
Solution
Enter the directory that contains some files you want to track: