【问题标题】:unable to merge master changes to my feature branch due to conflict由于冲突,无法将主更改合并到我的功能分支
【发布时间】:2018-07-14 02:28:01
【问题描述】:

我很难将主更改合并到我的功能分支。我只是尝试将主更改合并到我的功能分支以测试代码。我知道有些文件有冲突,但我认为我没有正确处理。

我尝试运行git pull 并收到以下错误。当我运行git checkout mybranch 并说needs merge. error: you need to resolve your current index first 时,您能指导我正确的方法吗?谢谢

git pull
error: Pulling is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.

【问题讨论】:

标签: git github


【解决方案1】:

在执行 git pull 命令之前,您似乎在 master 上有未提交或未暂存的文件。 git status 命令怎么说?

如果您有文件要提交到 master,请在将分支从 master 分支更改为您的功能分支之前提交它们。

如果您只需要在功能分支上提交这些文件,您可以这样做:

git stash
git checkout my_feature_branch
git stash pop

那么,这个分支的冲突就更容易解决了。

【讨论】:

    【解决方案2】:

    当您执行git merge 并遇到合并冲突时,您必须修复它们并提交或撤消与git merge --abort 的合并,然后才能再次拉取或签出另一个分支。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-01-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-22
      • 2021-07-30
      相关资源
      最近更新 更多