没什么可承诺的-Git [英] Nothing to commit - Git

查看:71
本文介绍了没什么可承诺的-Git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在github上为一个项目创建了一个新存储库,将其克隆并推送了2个文件:README.md和main.c.

I have created a new repository on github for a project, cloned it and pushed 2 files: README.md and main.c.

但是由于某些原因,每次我尝试使用

But for some reason every time I try to use

 git status

git add .

提交更改,我收到以下消息

to commit changes, I get the following message

# On branch master
nothing to commit (working directory clean)

所以我什么也不能推送,唯一可行的解​​决方法是

So I can't push anything and the only workaround solution that works is

rm -rf .git
git init
git remote add origin <repo>

并强制推送文件.推送更改后,它会返回到什么都没有提交"消息,因此每次我要提交时都必须重新初始化.

and force pushing the files. After I push the changes it goes back to the 'nothing to commit' message,so I have to reinitialise every time I want to commit.

即使我尝试重新克隆存储库,也会出现此问题.

This problem occurs even when I try to reclone the repository.

我一直在寻找解决方案,似乎.gitignore有时会导致类似的问题,但我在存储库中没有.gitignore文件.

I've looked around for solutions, it seems that .gitignore can sometimes cause similar issues but I don't have a .gitignore file in the repo.

推荐答案

git status -s --ignored 的输出是什么?如果您看到前面带有 !! 的任何内容,则表示它被某种方式忽略了.您必须显式添加任何被忽略的内容.此外,您必须使用 git add -f 强制执行此操作,否则git会对您大吼大叫,表示该文件已被忽略.例如: git add -f path/to/ignored_file.txt

What is the output of git status -s --ignored? If you see anything with a !! at the front, then that means it's being ignored somehow. You have to explicitly add anything that is being ignored. Moreover, you have to use git add -f to force it, otherwise git will yell at you saying the file is being ignored. For example: git add -f path/to/ignored_file.txt

这篇关于没什么可承诺的-Git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆