GIT not tracking files

拟墨画扇 提交于 2019-12-05 11:02:38

The output shows two things that are currently untracked:

  • ../index.html – the index.html file in the parent folder
  • ./ – the current folder, including all its contents

So it does detect that you have an untracked file, but because it does know nothing about its folder as well, it just shows the folder to accumulate all its content.

If you add your files and make Git track them, they will show up correctly:

git add index-2.html
git add ../index.html

It is tracking the folder ./ which means the current folder. git doesn't (correct me if I'm wrong), care about subfolders at all. Meaning if you have a repository with the folder foo, which is already in the repository. You add a subfolder bar in foo, and create a file foobar.txt in foo/bar. Then you will only get:

# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       ./bar

Which means that if you had done cd .. before your git status command, you would get:

# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       index.html
#       newfolder

even though you have a file inside.

The reason for this is that git tracks content, not files. Since index2.html actually is a content of the folder newfolder, and you are not tracking newfolder, git doesn't know that index2.html exists.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!