无需承诺 - Git
Nothing to commit - Git
我在 github 上为项目创建了一个新存储库,克隆了它并推送了 2 个文件:README.md 和 main.c。
但出于某种原因每次我尝试使用
git status
或
git add .
要提交更改,我收到以下消息
# On branch master
nothing to commit (working directory clean)
所以我无法推送任何内容,唯一可行的解决方案是
rm -rf .git
git init
git remote add origin <repo>
并强制推送文件。在我推送更改后,它会返回到 'nothing to commit' 消息,因此每次我想提交时我都必须重新初始化。
即使我尝试重新克隆存储库也会出现此问题。
我四处寻找解决方案,似乎 .gitignore 有时会导致类似的问题,但我的存储库中没有 .gitignore 文件。
git status -s --ignored
的输出是什么?如果您在前面看到任何带有 !!
的内容,则意味着它以某种方式被忽略了。您必须明确添加任何被忽略的内容。而且,你必须使用 git add -f
来强制它,否则 git 会大喊你说文件被忽略了。例如:git add -f path/to/ignored_file.txt
我在 github 上为项目创建了一个新存储库,克隆了它并推送了 2 个文件:README.md 和 main.c。
但出于某种原因每次我尝试使用
git status
或
git add .
要提交更改,我收到以下消息
# On branch master
nothing to commit (working directory clean)
所以我无法推送任何内容,唯一可行的解决方案是
rm -rf .git
git init
git remote add origin <repo>
并强制推送文件。在我推送更改后,它会返回到 'nothing to commit' 消息,因此每次我想提交时我都必须重新初始化。
即使我尝试重新克隆存储库也会出现此问题。
我四处寻找解决方案,似乎 .gitignore 有时会导致类似的问题,但我的存储库中没有 .gitignore 文件。
git status -s --ignored
的输出是什么?如果您在前面看到任何带有 !!
的内容,则意味着它以某种方式被忽略了。您必须明确添加任何被忽略的内容。而且,你必须使用 git add -f
来强制它,否则 git 会大喊你说文件被忽略了。例如:git add -f path/to/ignored_file.txt