我有四个分支(master, b1, b2和b3)。我在b1-b3上工作后,我意识到我在分支主上有一些应该在所有其他分支中更改的东西。我改变了我在master中需要的东西…这是我的问题:

我如何用主分支代码更新所有其他分支?


当前回答

从master更新你的分支:

  git checkout master
  git pull
  git checkout your_branch
  git merge master

其他回答

你有两个选择:

第一个是合并,但是这为合并创建了一个额外的提交。

检查每个分支:

git checkout b1

然后合并:

git merge origin/master

然后推:

git push origin b1

或者,你可以做一个rebase:

git fetch
git rebase origin/master

Git checkout master git拉 Git签出feature_branch Git重基master Git push -f

你需要做一个强有力的推动后,对主调基

您可以合并,也可以使用git的选择性跨分支应用单独的提交。

从master更新你的分支:

  git checkout master
  git pull
  git checkout your_branch
  git merge master

如果你想要恢复到上一次提交并删除日志历史记录

使用下面的命令,让我们假设你想要去到以前的提交,它有commititid SHA - 71e2e57458bde883a37b332035f784c6653ec509,你可以指向这个提交,它将不会显示任何日志消息在这个提交之后,所有的历史将被擦除。

git push origin +71e2e57458bde883a37b332035f784c6653ec509^:master