不知道为什么会这样:
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)
(commit or discard the untracked or modified content in submodules)
modified: file (modified content)
no changes added to commit (use "git add" and/or "git commit -a")
starkers@ubuntu:~/Documents/currentWork/protection_demo$ git add --all
starkers@ubuntu:~/Documents/currentWork/protection_demo$ 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)
(commit or discard the untracked or modified content in submodules)
modified: file (modified content)
无论我做什么,git commit -am
,git commit -a
文件都不会被添加到提交中。有帮助吗?
我想也许Jubobs的评论是正确的。你的“文件”是子模块吗?
对于普通文件,不应出现此行(提交或丢弃子模块中未跟踪或修改的内容)。
这是我从git状态得到的:
$ 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: README.txt
no changes added to commit (use "git add" and/or "git commit -a")
在README.txt之后,您将看不到(提交或丢弃子模块中未跟踪或修改的内容)和(修改后的内容)
所以你可能需要做git推荐的工作,处理子模块中的内容。
编辑:以前我认为“git add”。可以解决问题,但现在我认为不可能。
git reset .
这对我有用。 unstaging所有准备好提交包含的(修改内容)文件的文件
备份有问题的文件。删除这些文件集,提交删除,一次推送到源。
从备份中添加文件并发出新的添加,提交和推送。问题将得到解决。
您可以通过三种方式添加文件
git add filenamewithpath
git add .
git commit -a -m 'your commit message'
我有同样的问题。我个人的“啊哈”是我以前在子文件夹中添加了跟踪.git存储库文件,因此它被视为子模块。删除子文件夹中的.git后,它很高兴地加入了我的其余文件夹,作为根文件夹中一个.git文件的一部分。我甚至都不知道子模块,所以也许这对某些人也有帮助。
不确定这是否相关,但在Linux和Windows之间切换时遇到了同样的问题。我有2个文件,一个WEB.config和另一个web.config,因为Windows不区分大小写似乎已经混淆了。我重命名了提交重命名的文件,并再次提交似乎有工作。
有同样的问题,不明白为什么但.h文件不会提交。
所以,我重命名了它,这个删除的原文并创建了一个新的git担心。然后我提交了这些更改。 Git很高兴。
然后我重新命名了。 git很高兴承诺。
无法解释为什么会发生这种情况,但至少它是固定的。
昨天我发生了这件事,在我的情况下,原因是因为我试图从我项目的子目录中调用git。然后我用“git add --all”它解决了问题,我也去了正确的目录上面也解决了问题。
但我没有得到的是:为什么在世界上git status和git --all命令无论如何都在子目录中工作? .-。
希望它有帮助=)
这种类似的事情发生在我身上。无论我做了什么,文件都出现了修改。当看到差异时,它就像我在之前的提交中所做的那样被改变了。即使在第一次提交后,该文件似乎总是被修改。最后我删除了该文件。承诺删除,似乎我删除了两个文件。然后再次添加文件。我以前从未见过的奇怪的事情。
我有同样的错误:
fatal: Cannot update paths and switch to branch 'develop' at the same time.
然后用git status
:
$ git status
warning: LF will be replaced by CRLF in .gitmodules.
The file will have its original line endings in your working directory.
On branch develop
Your branch is up-to-date with 'origin/develop'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: .gitmodules
new file: submodule_dir
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)
(commit or discard the untracked or modified content in submodules)
modified: submodule_dir (modified content)
和git diff
显示:
$ git diff
diff --git a/somedir b/somedir
--- a/somedir
+++ b/somedir
@@ -1 +1 @@
-Subproject commit some-commit-hash
+Subproject commit some-commit-hash-dirty
问题是我试图添加一个在子模块库中尚不存在的分支。
另一种选择是同一个文件存在于存储中并且与当前副本冲突。
如果是这种情况,git stash drop
- 将删除存储(文件冲突)并允许您将修改后的文件添加到索引。