gpt4 book ai didi

Git:不添加暂存文件

转载 作者:太空狗 更新时间:2023-10-29 13:12:16 26 4
gpt4 key购买 nike

我对文件进行了更改。在尝试使用 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 -Agit add -u 或使用交互式暂存的暂存。

我很困惑,也没有真正理解为什么我的 reg git add 没有工作,我开始使用 git add -A。故事变得奇怪。在我的机器上重新启动后(2011 Macbook Air 运行 Mavericks)我在同一个文件上再次尝试了 good 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 之所以有效,是因为它暂存存储库中的所有文件,而不管您在目录中的位置。

关于Git:不添加暂存文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21358205/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com