Reputation: 53
Someone said that files in staging area will be clear after commit.
Someone said that files in staging area will not be cleared after commit.
Which one is correct?
Update: Thanks for the responses.
Based on my understandings, staging area is the index.
I use "git ls-files --stage" command to show the file listed in the index.
Before adding file to staging area with add command, it is empty.
After adding file to staging area (before commit), it show the file name.
After commit, it still show the filename. I think it is still listed in the index.
Is this the correct way to do it?
I want to know it because I want to understand "git reset --mixed" command.
Upvotes: 0
Views: 717
Reputation: 534977
Someone said that files in staging area will be clear after commit. Someone said that files in staging area will not be cleared after commit. Which one is correct?
The second is more correct. If you say git commit
plain and simple, the files in the staging area will match the files in the commit you just made — because that's what the staging area is, namely, the place where you specify what will go into the next commit. Which, in effect, by and large, more or less, will be all the files in your project. That's what a commit is: a snapshot of (roughly) the entire state of the project.
It looks like the staging area is empty, maybe, because git status
doesn't list any files ready to be committed. But that's merely because you just did commit them, so there are no differences between the stage and the last commit. As you have already found, you can readily explore what's in the staging area with ls-files
and prove it.
I want to know it because I want to understand "git reset --mixed" command.
Well, I don't see how it will help with that, but okay.
Upvotes: 1