排除错误放置的.git目录(无法提交) [英] Troubleshooting misplaced .git directory (nothing to commit)

查看:110
本文介绍了排除错误放置的.git目录(无法提交)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始收到这条消息。无论我编辑并尝试提交,它都说没有什么可以提交的。看起来像git没有看到我的工作目录,并寻找其他地方。

I started getting this message. No matter what I edit and try to commit, it says there is nothing to commit. Looks like git does not see my working directory and looking somewhere else.

如果我运行 git status ,它会输出相同的结果:

If I run git status it outputs the same:

nothing to commit (working directory clean)

如果我创建新的分支并编辑一些东西,然后发生同样的事情。当我需要解决合并冲突时,这开始发生。当我想将我的一个分支与主分支合并时,我不得不手动修复它,并且我需要我的文件完全像在该分支覆盖主分支那些相同的文件。所以我添加了这些文件,它让我合并它。但是,无论我改变什么,它都会显示,因为没有什么可以提交的。

If I create new branch and edit something, then same thing happens. This started happening when I needed to fix merge clashes. When I wanted to merge my one branch with master branch, I had to manually fix it and I needed my files to look exactly as in that branch overwriting master branch those same files. So I added those files and it let me merge it. But then no matter what I change it shows as there is nothing to commit.

在这里可以做些什么?

What could be done here?

推荐答案

。我不明白如何,但 .git 目录路径以某种方式更改为其他路径,而不是我工作。所以,然后我更改的任何内容都没有检查,因为git正在检查在其他地方。我注意到了,当我重新初始化它时,它表明它重新初始化完全不同的目录。当我从当前目录中选择 cd .. 并且 cd 重新返回,然后再重新初始化时,回到正确的 .git 目录并开始看到我的更改。

Found what was wrong. I don't understand how, but .git directory path somehow was changed to other path than I was working in. So then anything I changed was not checked, because git was checking in other place. I noticed it, when I reinitialized it and it showed that it reinitialized entirely different directory. When I cd .. from my current directory and cd to it back again and then reinitialized yet again, then it switched back to correct .git directory and started seeing my changes.

这篇关于排除错误放置的.git目录(无法提交)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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