Information Technology Reference
In-Depth Information
When you create the commit for the first time both
Author
and
Commit
will be
set to your name. The dates stored in
AuthorDate
and
CommitDate
will be the
same. This situation is shown in
Listing 8-1
.
What happens if you modify the commit with the
--amend
option? Git preserves
the original
Author
and
AuthorDate
fields and sets new values for the
Commit
you cherry-pick or rebase your commits.
Hint
Git doesn't care about the last modification dates of your files. Git tracks con-
tents—the last modification dates of your files do not influence your revisions in any
way. Every commit stored in the database contains
AuthorDate
and
CommitDate
.
These dates are set when you commit, rebase, or cherrypick. The last modification dates
of the files are set when you check out the files. This is done when you switch branches,
for example.
A careful reader will notice that the authorship of changes introduced by
$ git
commit --amend
is wrongly attributed to the original author. In Recipe 8-1 two
words
Ipsum
and
Dolor
were authored by the user John Doe but are attributed to
Włodzimierz Gajda. In practice this never happens, however, because you are not al-
lowed to amend commits authored by other developers. You can cherry-pick or rebase
them, but then the authorship is attributed correctly.
8-2. Removing
n
most recent revisions
Problem
You want to remove from your current branch the two most recent revisions. The trans-
formation you want to achieve is depicted in the
Figure 8-1
.