Reputation: 3430
I'm reading the Pro Git book and the definitions for tracked and untracked aren't 100% clear to me.
From the book: "Tracked files are files that were in the last snapshot; they can be unmodified, modified, or staged. Untracked files are everything else — any files in your working directory that were not in your last snapshot and are not in your staging area."
Here's a link to the chapter in case you want more context: http://git-scm.com/book/en/Git-Basics-Recording-Changes-to-the-Repository
What's confusing me is the phrase "last snapshot." The staging area(or index if you prefer that term) is considered a snapshot, and a commit is a snapshot as well, correct?
I also have a few simple scenarios that I'd like clarification on which would really clear this concept up for me:
Scenario 1: Say I have files A and B. I commited A, then afterward I stage B. Is B tracked and A untracked because the staging area was the most recent snapshot?
Scenario 2: Say I have files A and B. I committed A, then afterward I commit B.
Is A considered untracked?
Scenario 3: I perform a git clone putting some file X into my local repository. X is tracked because my local repository is my most recent (only) snapshot?
Upvotes: 0
Views: 1850
Reputation: 78663
I admit that this could use clarification in the book. My reading (and the common terminology which is used by many tools) is that the "last snapshot" means the HEAD commit; in this terminology, "last snapshot" is never referring to the index. Thus, a file has an "untracked change" if it's neither in HEAD nor in the index.
Scenario 1: No. Both A and B are tracked, since A is in HEAD and B is staged.
Scenario 2: No. Both A and B are in HEAD.
Scenario 3: Yes. X is in HEAD.
You will have an "untracked" file if you simply create some file C without adding it or committing it.
Recall further that a commit is a representation of the repository at that time. So if you add and commit some files A
and B
, and make further commits (that don't change A
or B
) then these files still exist in the HEAD commit. So (regardless of how long they've been in the repository) they're still considered "tracked" until you delete them.
Upvotes: 3
Reputation: 13709
The way I understand it, tracked files are everything you've git add
ed or have committed. Any other files git will see on your file system, but is not tracking them. That is, it's not keeping a record of changes to those files.
Upvotes: 2