当前位置:   article > 正文

Git Merge代码失败 解决_no merge base

no merge base

目录

■Merge时出现问题 (Eclipse中)

■原因

■解決

■解決 方案一 (GitBash命令行)

■解決 方案二 (TortoiseGit) (采用此方案,解决了!)

●TortoiseGit中的Merge选项设置

●Eclipse  Git plugin中的Merge选项 (只是用作和上面对比)

■解決 方案三

■其他

●Git的Merge选项

    ●Squash

   ①Fast-forward

   ②【M】--no-ff // non-Fast-forward // git merge

   ③【N】--ff-only Fast-forward 模式:

●Git的三个工作区域

●Git的三中Reset操作

●Git的三中Reset操作之---Hard---命令行操作   &【更多Git命令!!!】

■Reset使用场景 (取消本地的Commit)

■更多命令行操作


■Merge时出现问题 (Eclipse中)


No merge base could be determined. Reason=CONFLICTS_DURING_MERGE_BASE_CALCULATION. 
Multiple commond ancestors were found and merging them resulted in a conflict:
ae808ae08a0e8a08e0a, adad808eae8a0e8a  // 提交的commitID

  1. No merge base could be determined.
  2. Reason=CONFLICTS_DURING_MERGE_BASE_CALCULATION. 
  3. Multiple commond ancestors were found and merging them resulted in a conflict:
  4. // determined. [dɪˈtɜːmɪnd]
  5. adj. 决心; 决定; 决意; 坚定的;
  6. v. 查明; 测定; 准确算出; 决定;

■原因

网上说这是Eclipse Git plugin的一个bug。 确实如此!

eclipse - Multiple common ancestors were found and merging them resulted in a conflict - Stack Overflow

■解決

■解決 方案一 (GitBash命令行)


1.gitbushロックイン

git pull

执行上面的命令后,便会让你输入用户,密码


2.切换branch

git checkout master

3.查看当前Brach    (查看当前 所在分支)

  1. git branch // 查看分支
  2. git log // 查看提交记录
  3. git log -2 查看最近2次的提交历史记录
  4. git status // 查看当前 所在分支

执行切换分支命令时,Eclipse中的工程会跟着变化

4.下記コマンド実行

git merge --no-commit origin/dev_branchname


■備考 (方案一)
#形式一
git merge [-n] [--stat] [--no-commit] [--squash] [--[no-]edit]
    [--no-verify] [-s <strategy>] [-X <strategy-option>] [-S[<keyid>]]
    [--[no-]allow-unrelated-histories]
    [--[no-]rerere-autoupdate] [-m <msg>] [-F <file>] [<commit>…​]
#形式二
git merge (--continue | --abort | --quit)

■解決 方案二 (TortoiseGit) (采用此方案,解决了!)

   使用 Tortoise (Merge)

      不需要登录Git,(但是需要输入用户名和邮箱即可)

      Merge操作是在本地的Git上进行的。

---

---

(初次使用时才有)

 ---

(初次使用时才有)

 ---

●TortoiseGit中的Merge选项设置

Merge之后,Eclipse中,会显示Merge的代码,在【stage】区域,

检查代码之后,就可以在Eclipse中提交了。

●Eclipse  Git plugin中的Merge选项 (只是用作和上面对比)

 

Eclipse中的Merge设置,可以参照下面内容

GIT命令行的一些基本操作_sun0322-CSDN博客

---

---

■解決 方案三

 换一个版本的 Eclipse

■其他

●Git的Merge选项

    ●Squash

(多个commit记录合并成一个提交记录) 

  1.   git merge コマンドを実行するときに、
  2.   --squash オプションを指定すると、
  3.   ブランチ先でのすべてのコミットを1つにまとめて、
  4.   現在チェックアウトしているブランチにステージングすることができます。

---

   ①Fast-forward

是指 Master 合并 Feature 时候发现 Master 当前节点一直和 Feature 的根节点相同,
没有发生改变,那么 Master 快速移动头指针到 Feature 的位置,
所以 Fast-forward 并不会发生真正的合并,【只(only)】通过移动指针(pointer)造成合并的假象,
这也体现 git 设计的巧妙之处。
(如果不匹配则执行 --no-ff(non-Fast-forward) 合并模式)

   ②【M】--no-ff // non-Fast-forward // git merge

当合并的分支跟 master 不存在共同祖先节点的时候,这时候在 merge 的时候 git 默认无法使用 Fast-forward 模式,
git自己【Merge代码】


   ③【N】--ff-only Fast-forward 模式:

只会按照 Fast-forward 模式进行合并,如果【不符合】条件(并非当前分支的直接后代),则会拒绝合并请求并且推出

---

●Git的三个工作区域

  1. 1.Working
  2. Working Tree 当前的工作区域
  3. 2.Stage
  4. (先把代码添加到这里,然后提交)
  5. Index/Stage 暂存区域,和git stash命令暂存的地方不一样。
  6. 使用git add xx,就可以将xx添加近Stage里面
  7. 3.Repository
  8. Repository 提交的历史,即使用git commit提交后的结果

●Git的三中Reset操作

git reset 的三种模式的使用场景_雕牌咸鱼的博客-CSDN博客_git reset 三种模式

①git reset --soft
②git reset --mixed
③git reset --hard

③git reset --hard

git reset --hard HEAD^ 回退到上个版本
git reset --hard HEAD~3 回退到前3次提交之前,以此类推,回退到n次提交之前
git reset --hard commit_id 退到/进到,指定commit的哈希码(这次提交之前或之后的提交都会回滚)

●Git的三中Reset操作之---Hard---命令行操作   &【更多Git命令!!!】

  1. ●登录
  2. git pull // 输入这个命令后(其他命令应该也行),会让你输入用户名,密码
  3. ●查看分支
  4. git branch // 查看分支
  5. ●切换到你的分支,并确认
  6. git checkout branch_name // 切换到你要合并的分支,并拉取最新的代码
  7. git status // 查看当前在
  8. ●查看提交记录
  9. git log -2 查看最近2次的提交历史记录
  10. ●回退命令:
  11. git reset --hard HEAD^ 回退到上个版本
  12. git reset --hard HEAD~3 回退到前3次提交之前,以此类推,回退到n次提交之前
  13. git reset --hard commitID 退到/进到,指定commit的哈希码(这次提交之前或之后的提交都会回滚)

■Reset使用场景 (取消本地的Commit)

・本地Git仓库,已经有了Commit的记录

・本地的Commit,没有PUSH。(即,远程git仓库,没有这条记录)

这时,在Ecliplse中,按照下面方式操作,是无法回退到远程Git的最新版本的

 需要在回退时,指定,远程Git的最新版本的CommitID,才能回退。

比如,Head时,使用如下命令,取消本地的Commit

  1. git log -2 查看最近2次的提交历史记录 // 获得commitID
  2. git reset --hard commitID

---

■更多命令行操作

GIT命令行的一些基本操作_sun0322-CSDN博客

---

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/321380?site
推荐阅读
相关标签
  

闽ICP备14008679号