无法解决Git上的冲突(远程比本地多1次提交)

huangapple go评论59阅读模式
英文:

Cannot resolve conflict on Git (remote is 1 commit ahead)

问题

I understand you want a translation of the provided text without any additional information. Here's the translation:

我正在进行的一个项目有大约200个子模块。我在我的本地仓库中对大约150个子模块进行了一些修改,但没有提交和推送。

但事实证明,就在我准备提交和推送时,我注意到另一位队友最近在远程仓库中进行了一次推送。现在,远程仓库比我的本地多了一个提交。

我的尝试解决方案:

1)每当我尝试推送我的更改时,它都会说不可能,因为远程仓库领先。所以我试图强制推送我的更改(我和队友都同意我可以这样做),但是这个分支受到管理员的保护,无法完成。

2)由于这没有起作用,我尝试简单地拉取最新的更改,并递归更新子模块(submodule update --init -recursive)。我得到以下错误:

“错误:以下文件的本地更改将被检出覆盖”

在Git扩展的输出错误窗口中:

无法解决Git上的冲突(远程比本地多1次提交)

您将如何解决这个问题?

英文:

A project that I'm working on has around 200 submodules. I made some modifications in my local repo, around changes to 150 submodules without commit & pushing.

But it turns out that just when I was about to commit & push, I noticed that another teammate had made recently a push in the remote repo. Son now, the remote repo is one commit ahead from my local.

My attempted solutions:

  1. Whenever I try to push my changes, it says that it can't be possible because the remote repo is ahead.
    So I tried to force push my changes (my teammate and I agreed that I can do this), but the branch is protected by an administrator. I can't be done.

  2. Since that didn't worked, I tried to simply Pull the latest changes and updating recursively the submodules (submodule update --init -recursive). I'm getting the following error:

error: Your local changes to the following files would be overwritten by checkout

In Git Extensions output error window:

无法解决Git上的冲突(远程比本地多1次提交)

What would you do to solve this issue?

答案1

得分: 2

git stash的作用是将未提交的更改保留,直到您准备好使用它们。在解决冲突后,您可以使用git stash popgit stash apply将这些更改放回您的工作目录中(pop会从列表中删除存储;apply则不会)。

更多文档可在https://git-scm.com/docs/git-stash找到。

英文:

git stash was made for this: it sets uncommitted changes aside until you're ready for them. You can use either git stash pop or git stash apply to put those changes back into your working directory after you've resolved your conflicts. (pop removes the stash from the list; apply does not.)

There's more documentation available at https://git-scm.com/docs/git-stash.

huangapple
  • 本文由 发表于 2023年4月20日 00:45:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/76056983.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定