[英]Files untracked in git not part of .gitignore
I did not include them in the.gitignore but they got untracked.我没有将它们包含在 .gitignore 中,但它们未被跟踪。 Actually I added a pychache to the gitignore and was hoping that would also clean up the remote (it did).
实际上,我在 gitignore 中添加了一个pychache ,并希望这也能清理遥控器(确实如此)。 Then out of curiosity I wanted to see what was in the index and what fiels were being tracked so I ran some commands I saw on SO.
然后出于好奇,我想看看索引中有什么以及正在跟踪什么字段,所以我运行了一些我在 SO 上看到的命令。
Specifically ones like: git ls-tree --full-tree --name-only -r HEAD
具体如下:
git ls-tree --full-tree --name-only -r HEAD
Then I did a git status and noticed a lot of my files that I was not ignoring (including the.gitignore ironically) were now considered untracked.然后我做了一个 git 状态并注意到我没有忽略的很多文件(包括讽刺的.gitignore)现在被认为是未跟踪的。 I'm not sure what I did to make this happen.
我不确定我做了什么来实现这一点。
Note that I'm in a virtual environment.请注意,我在虚拟环境中。 I don't think that would affect anything.
我认为这不会影响任何事情。
Note that these were not actually deleted from my local workspace so nothing was lost, but they stopped getting tracked and consequently were deleted from remote and were not being committed.请注意,这些实际上并没有从我的本地工作区中删除,因此没有丢失任何内容,但是它们停止被跟踪,因此被从远程删除并且没有被提交。
To recommit them I had to add them back specifically by name, so not with git add.
要重新提交它们,我必须按名称专门将它们添加回来,所以不要使用
git add.
but with git add../License
但使用
git add../License
Why is this?为什么是这样?
To recommit them I had to add them back specifically by name, so not with git add.
要重新提交它们,我必须按名称专门将它们添加回来,所以不要使用 git 添加。 but with git add../License
但使用 git add../License
You are not in the root directory of your repository.您不在存储库的根目录中。
git add.
means "add everything from the current directory ( .
), recursively".表示“递归地添加当前目录 (
.
) 中的所有内容”。 It does not propagate to parent directory.它不会传播到父目录。
If you run git add.
如果你运行
git add.
from the root directory of the repository, it does what you expect.从存储库的根目录中,它可以满足您的期望。 You could also do
git add -A
from any directory within the repository.您还可以从存储库中的任何目录执行
git add -A
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.