git - 重新设置一个分支,包括它的所有子分支

标签 git version-control branch rebase git-rebase

我有以下 Git 存储库拓扑结构:

A-B-F (master)
   \   D (feature-a)
    \ /
     C (feature)
      \
       E (feature-b)

通过 rebase feature 分支,我希望对整个子树(包括子分支)进行 rebase :

$ git rebase feature master

A-B-F (master)
     \   D (feature-a)
      \ /
       C (feature)
        \
         E (feature-b)

然而,这是实际的结果:

      C' (feature)
     /
A-B-F (master)
   \   D (feature-a)
    \ /
     C
      \
       E (feature-b)

我知道我可以通过执行以下命令轻松地手动修复它:

$ git rebase --onto feature C feature-a
$ git rebase --onto feature C feature-b

但是有没有办法自动 rebase 分支,包括它的所有子/后代?

最佳答案

git branch --format='%(refname:short)' --contains C | \
xargs -n 1 \
git rebase --committer-date-is-author-date --onto F C^

关于git - 重新设置一个分支,包括它的所有子分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5600659/

相关文章:

git - 当你是 git 的原始仓库时,你如何进行本地 pull ?

git - SmartGIt "Not all refs have been pushed"错误

git - 如何区分 ansible vault 的变化?

git - sh : parse_git_branch: command not found

git - 如何删除所有已 merge 的 Git 分支?

python - 初始化 DVC 存储库会引发错误

version-control - "bzr uncommit"在 Mercurial 中等效吗?

flash - Adobe Flash 项目的版本控制

git - 在 TortoiseGit 中,git branch -d 的等价物是什么(没有 --force 选项)?

Git 工作流程 : merging branches while avoiding repetitive commit messages