Does git commit –amend include the files that were in the last commit?
The git book seems to contradict itself re
git commit --amend:
This command takes your staging area and uses it for the commit. If
you’ve made no changes since your last commit…, then your
snapshot will look exactly the same and all you’ll change is your
Git authentication over apache_mod_krb Need help understanding the Git icons in Eclipse How do I delete a remote branch in Git? Why did my Git repo enter a detached HEAD state? Git bash won't let me pull “nothing to commit (working directory clean)” when a folder has been added
First it says, “This command takes your staging area and uses it for the commit.”
Now, if I run
git add -A; git commit -m "Initial"; git status; the status message says the staging area is empty.
Then the book says, “If you’ve made no changes since your last commit … your snapshot will look exactly the same…”
Now, if it uses my (empty) staging area for the commit, shouldn’t the amended commit be empty? The amended commit isn’t empty though, it includes the files that were in the last commit.
It seems that the git book should read:
This command takes your staging area, adds it to the last commit, and creates a new commit from the combination…
Please help me out here. What, if anything, am I missing?
One Solution collect form web for “Does git commit –amend include the files that were in the last commit?”
The wording is a bit awkward, but your interpretation is correct. That’s exactly what
The book seems to be saying that it won’t automatically add unstaged changes to the commit.
What happens instead, as you correctly note (and as the book does say, in an unclear way in my opinion), is that the old commit is replaced with another commit, which has the same changes as the original but a (Potentially) new commit message and a new timestamp and commit hash. That’s what it means by snapshot: the state of the repo at that moment in time.
Of course, if you DID have staged changes, those changes will be rolled into the new commit.