git subtree pull 表示工作树已修改,但 git status 表示没有。什么给?
如果我在我的一个存储库中执行此操作:
git subtree pull --prefix=frameworks/AquaticPrime --squash AquaticPrime
我得到这个:
Working tree has modifications. Cannot add.
如果我执行此操作(当然,在同一个地方):
git status
我得到这个:
# On branch master
nothing to commit (working directory clean)
我不太确定这里发生了什么。 git status 命令意味着我没有修改,所以我假设 git subtree pull 指的是与子树相关的不同分支中的修改,但并不完全清楚。
有人可以提供启示吗?
If I do this in one of my repositories:
git subtree pull --prefix=frameworks/AquaticPrime --squash AquaticPrime
I get this:
Working tree has modifications. Cannot add.
If I do this (in the same place, of course):
git status
I get this:
# On branch master
nothing to commit (working directory clean)
I'm not quite sure what's going on here. The git status command implies that I don't have modifications, so I'm assuming that the git subtree pull is referring to modifications in a different branch related to the subtree, but it's not entirely clear.
Can anyone provide enlightenment?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
我刚刚遇到了同样的问题。
从 GIT 源代码来看,当命令 git diff-index HEAD 返回结果时,即使 git status 表示工作树是干净的,也会引发错误。
为了避免这个错误,在我的例子中,我重新签出工作树的当前分支,一切似乎都正常:
git checkout
这有点困惑,但如果有人可以解释为什么。 ..
I just had the same problem.
From GIT source, error is thrown when command
git diff-index HEAD
returns result, even ifgit status
says working tree is clean.To avoid this error, in my case, I re-checkout the current branch of working tree , and everything seems OK :
git checkout <branch>
It's a bit confused, but if someone can explain why ...
git reset --hard
将其修复给我来自
git reset --help
git reset --hard
fixed it to meFrom
git reset --help
我现在解决了这个问题。在我看来,我的问题是该存储库是全新的:我从未向它提交过任何内容。一旦我将文件提交到存储库,我就能够克服这个错误。
但是,使用命令 git subtree add C:\gitTest\repos\subA -d --prefix subA 我收到了新错误:
致命的你期望我如何合并 0 棵树? 搞乱了
一分钟后,我发现它需要将特定的修订传递给它。所以这个命令似乎已经成功:
git subtree add C:\gitTest\repos\subA HEAD -d --prefix subA
显然你不需要 -d 调试标志。
I got around this now. My problem seemed to me that the repository was brand new: I had never committed anything to it. Once I committed a file to the repo, I was able to move past this error.
However, using the command
git subtree add C:\gitTest\repos\subA -d --prefix subA
I got the new error:fatal just how do you expect me to merge 0 trees?
After messing around for a minute, I figured out it requires that a specific revision be passed to it. So this command seems to have succeeded:
git subtree add C:\gitTest\repos\subA HEAD -d --prefix subA
And obviously you don't need the -d debug flag.
我刚刚遇到这个问题,当我:
尽管 puppet diff 正确地没有显示任何内容,但 git diff-index HEAD 将我刚刚删除的每个文件都列为“已删除”,尽管我从未这样做过提交(更不用说推送)任何东西。
我相信,这是 git 中的一个错误(此处使用 2.7.0)...无论是否有错误,解决方法是切换到任何其他分支(使用通常的 git checkout ....),然后回到你的。希望这对某人有帮助——即使不是最初的提问者。
I just had this problem, when I:
Although
puppet diff
was -- correctly -- showing nothing, thegit diff-index HEAD
listed each of the files I just deleted as "deleted" -- even though I never commit-ed (much less push-ed) anything.I believe, this is a bug in git (using 2.7.0 here)... Bug or not, the work-around is to switch to any other branch (with the usual
git checkout ....
) and then back to yours. Hope, this helps someone -- even if not the original asker.如果您使用的是 Windows,请尝试使用 Git Bash 而不是 PowerShell 或 cmd.exe。
这解决了我的问题。
If you are using Windows, try to use Git Bash instead of PowerShell or cmd.exe.
This fixed the problem in my case.
我有完全相同的错误。这发生在我的功能分支上。修复:
我不知道为什么我必须掌握并合并到我的功能分支,但这解决了问题。
I had the exact same error. This was occurring on my feature branch. The fix:
I have no clue why I had to get master and merge to my feature branch, but that solved the issues.
我在使用 SourceTree 时遇到了这个问题。问题是当我设置子树时,我选择了一个现有文件夹。有一个警告,但我忽略了它。再次设置子树,但输入新的文件夹名称(尚不存在)解决了该问题。
I had this problem with SourceTree. The problem was when I set up the subtree, I was selecting an existing folder. There was a warning but I ignored it. Setting up the subtree again but typing in a new folder name (one that doesn't exist yet) fixed the issue.
在尝试执行修改存储库的 Git 命令(例如
git subtree add
)之前,请确保已提交对本地 Git 存储库所做的所有更改。这将避免由于开放提交而可能出现的任何问题Ensure that all changes made to your local Git repository have been committed before attempting to execute Git commands that modify your repository, such as
git subtree add
. This will avoid any issues that might occur due to open commit我这样做是作为项目中的第一次提交,很奇怪(git 分支)没有显示任何内容。我做了一个 tmp 提交,然后它就起作用了
I was doing this as the first commit in a project and it was weird (git branch) showed nothing. I made a tmp commit and then it worked
尝试在不使用
--squash
的情况下进行拉取,如此 stackoverflow 问题中所述。Try to pull without
--squash
as it is described in this stackoverflow question.