What are tracked files and untracked files in the context of Git?

前端 未结 5 2002
逝去的感伤
逝去的感伤 2021-02-02 08:14

I\'m new to Git. I wish to know what are tracked and untracked files? I read \"Pro Git\", but still couldn\'t quite understand.

Can someone explain to

5条回答
  •  Happy的楠姐
    2021-02-02 08:57

    From a purely technical perspective: A tracked file is simply a file that exists in the Git index. To say it's a file "under version control" is misleading, because this suggests that it's a file that made it into the repo--and that's not necessary for a file to be tracked.

    When you init a new Git repo, the index is empty and all files in your working directory are untracked. A file gets tracked when it's added to the index--at which point a SHA-1 hash is created for it and an object entry is placed into the .Git\Objects folder. From that moment on, Git is able to compare the contents/name of the same file in the working directory in order to track changes, renames, and deletes. As long as the file exists in the index, it is tracked.

提交回复
热议问题