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
How to use the forked repo and still track updates from the original source How to setup gitconfig for default remote name? How to 'pipe' password to remote.update() with gitPython github pull-request with merging issues Can't push master branch to git repository with netbeans GitHub for Windows says that there are uncommited changes even though the diffs are empty
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.