Git合并显示已是最新,但我的文件未更改。

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

Git merge says up to date but my files didn't change

问题

I have 2 branches, main and Android. Android branches has some plugins for android environment. I updated my android with main branch, git history shows changes but when I inspect files there is no changes. Even git diff shows my files is not same with android yet shows no changes on untracked list. How can I fix this?

当我尝试合并时出现冲突,我忽略了它。放弃了Android分支上的所有更改,然后尝试再次合并。当我这样做时出现了问题。我认为在尝试合并时放弃Android分支上的所有更改导致了所有这些问题。

I tried git reset --hard Android and git checkout. None of these worked.

我尝试了git reset --hard Androidgit checkout,但都没有奏效。

英文:

I have 2 branches, main and Android. Android branches has some plugins for android environment. I updated my android with main branch, git history shows changes but when I inspect files there is no changes. Even git diff shows my files is not same with android yet shows no changes on untracked list. How can I fix this?

When I try merging there was conflict and I ignored it. Discarded all changes on Android branch and try merging again. The problem occured when I do this. I think discarding all changes on Android branch when I try merging it caused all this problem.

I tried git reset --hard Android and git checkout. None of these worked.

答案1

得分: 0

听起来你在将主分支的更改合并到Android分支时可能遇到了合并冲突,但你通过放弃Android分支上的所有更改来解决了这个问题。这可能会导致合并看起来是“最新”的,因为Git认为没有需要合并的更改,但实际上,你已经丢失了Android分支上的更改。
你可以尝试从主分支创建一个新的分支,然后挑选要应用到Android分支的提交:

  • git checkout -b new-Android main
  • git cherry-pick <commit哈希值>

使用cherry-pick,你可以逐个提交地将它们引入你的分支,然后逐个手动解决每个代码冲突。

英文:

It sounds like you might have encountered a merge conflict when merging
the changes from the main branch into the Android branch, but you resolved it
by discarding all the changes on the Android branch. This can cause the merge to appear as "up to date" because Git thinks
there are no changes to merge, but in reality, you have lost the changes that were on the Android branch.
You can try creating a new branch from the main branch and cherry-picking
the commits that you want to apply to the Android branch:

- git checkout -b new-Android main 
- git cherry-pick &lt;commit hash&gt;

With cherry-pick, you can bring commit by commit into your branch, and with that, you can gradually resolve each code conflict manually.

huangapple
  • 本文由 发表于 2023年5月8日 02:42:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/76195696.html
匿名

发表评论

匿名网友

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

确定