[英]Git: add not staging files
我对文件进行了更改。 在尝试使用git add
文件后(像往常一样),我继续提交git commit -m
。 但是,终端向我吐出这个:
no changes added to commit (use "git add" and/or "git commit -a")
我检查了git status
:
#On branch master
#Changes not staged for commit:
#(use "git add <file>..." to update what will be committed)
#(use "git checkout -- <file>..." to discard changes in working directory) modified: ../../Round 1/R1C3/R1C3.py
在对管子进行了一些搜索之后,我发现我可以通过其他各种方式暂存文件,但不能使用没有标志的git add
。 我可以使用git add -A
或git add -u
或使用交互式登台进行登台。
困惑并且不真正理解为什么我的 reg git add
不起作用,我伪造了使用git add -A
。 故事变得很奇怪。 在我的机器上重新启动后(2011 Macbook Air running Mavericks)我在同一个文件上尝试了一些好的 ol' git add
......你猜怎么着? 有效。 所以我继续说。
现在,不久之后,我又遇到了同样的问题。 git add
将不起作用(同一目录)。
有谁知道我做错了什么? 由于上述替代方案,这并不是一个真正的大问题,但我想了解为什么会发生这种情况。 特别是因为这在过去一直对我有用,而今天,它坏了:(
**注意:我计算机上的其他版本控制项目似乎没有受到影响。
git add R1C3.py
git status
#On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: ../../Round 1/R1C3/R1C3.py
# no changes added to commit (use "git add" and/or "git commit -a")
git add -A
git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: ../../Round 1/R1C3/R1C3.py
#
当您执行git add
时,它应该与文件在同一目录中运行或传递文件的相对路径。 由于该文件位于父目录中,因此git add
将找不到该文件。 在您的情况下,您应该cd ../../Round 1/R1C3/
然后运行git add R1C3.py
。
git add -A
之所以有效,是因为它会暂存存储库中的所有文件,而不管您在目录中的位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.