【问题标题】:How to Merge Working Branch A into New Branch B Locally..?如何在本地将工作分支 A 合并到新分支 B..?
【发布时间】:2020-07-30 10:05:15
【问题描述】:

我有分支 A(我正在编码的地方),我已经确定我从 GitBash 创建的分支(分支 A)没有出现在 GitHub 存储库上。 完成的步骤:

git clone url@git.com
git checkout -b branchA

现在想从 git 把 master 放到另一个分支中。

git clone url@git.com
git checkout branchB ( I have created on Github)

现在想将分支 A 合并到分支 B 并使分支 B 处于活动状态...? 分享一些最好的命令或如何在本地合并而不会丢失我的代码和发生冲突..

谢谢各位。 JB

【问题讨论】:

  • 为什么需要 git clone 两次

标签: git git-bash merge-conflict-resolution git-gui


【解决方案1】:

首先尝试使用git diff FIRST-BRANCH..SECOND-BRANCH识别差异

我认为这对你的情况有用

git chechout branchA
git add .
git commit -m "msg"
git pull
git push origin branchB
git checkout branchB

建议您备份存储库以确保安全

【讨论】:

    【解决方案2】:

    如果你的分支没有显示在你的中心,可能你还没有推送它

    git checkout branch -B
    git add . 
    git commit -m "message"
    git push origin branch -B
    

    如果要合并两个分支

    git checkout "Branch in which you want to add"
    git merge "Branch which you want to add"
    git push origin "branch name"
    

    现在您将在 Github 上看到该分支中的所有提交

    【讨论】:

      猜你喜欢
      • 2016-03-07
      • 2016-11-20
      • 2020-08-09
      • 2020-10-11
      • 2018-10-24
      • 2015-06-23
      • 2018-12-20
      • 2019-12-06
      • 1970-01-01
      相关资源
      最近更新 更多