有没有办法编写一个别名,将分支合并回其父分支?我知道我能做到:
git checkout - && git merge -
但它仅适用于当我的上一个分支是父分支时的简单情况。
据我所知 git 不会跟踪此类信息,因为那里没有分支。但我希望它已经作为插件或钩子(Hook)集实现。
提前致谢。
最佳答案
这样的别名需要首先找到“父”分支。
这并不简单,问题“Find the parent branch of a branch”有一些很好的解决方案。
Git’s history is based on a DAG of commits. Branches (and “refs” in general) are just transient labels that point to specific commits in the continually growing commit DAG.
As such, the relationship between branches can vary over time, but the relationship between commits does not.
一旦获得父分支的名称,就可以在别名中使用它。
关于githooks - 如何让 git 将分支合并回父分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24404472/