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

前端 未结 5 1997
逝去的感伤
逝去的感伤 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条回答
  •  耶瑟儿~
    2021-02-02 09:14

    The Git Pro book chapter you mention tries to detail the notion of untracked file:

    When you checkout a given SHA1, you get a "snapshot" of all versioned files.
    Any file not referenced by this snapshot is untracked. It isn't part of the Git tree:
    See "git - how to tell if a file is git tracked (by shell exit code)?"

    Any file that you want to ignore must be untracked (as explained in this GitHub help page).

    Note that git will not ignore a file that was already tracked before a rule was added to the .gitignore file to ignore it.
    In such a case the file must be un-tracked, usually with git rm --cached filename

提交回复
热议问题