Information Technology Reference
In-Depth Information
The parameter --amend of the $ git commit command allows you to modify the
most recent revision in the history. The command $ git commit --amend :
• Takesthemostrecentcommitfromthehistory(inRecipe8-1itisthecom-
mit named 5a78 ; the file lorem.txt contains lorem ; the commit is
shown in Listing 8-1 )
• Takes the current state of the staging area (in Recipe 8-1 it is the staged
file lorem.txt with Lorem Ipsum Dolor )
• And combines them into a new revision (in Recipe 8-1 it is the commit
named f63b ; the commit is shown in Listing 8-2 )
This new revision ( f63b ) replaces the original revision ( 5a78 ) in the history.
Technically speaking the command doesn't modify a revision. It creates a new com-
mit. You can find the names of both commits using the $ git reflog command.
The original commit remains dangling in the git database until it is finally deleted by a
garbage collection operation.
Hint Remember—git revisions are permanent! It is not possible to change any in-
formation stored in a commit and preserve the same SHA-1. The $ git commit --
amend command creates a brand new revision and then updates the master branch to
point to the new revision.
Why did we change the user.name and user.email configuration in this re-
cipe? It will help you to understand the way git handles dates and assigns authorship.
Every commit contains four attributes: Author , AuthorDate , Commit , and Com-
mitDate . They store:
Author —the name of the author
AuthorDate —the date when the commit originally was made
Commit —the name of the committer
CommitDate —the date when the commit was introduced in the history
Search WWH ::




Custom Search