githooks - 如何让 git 将分支合并回父分支

标签 githooks git-alias

有没有办法编写一个别名,将分支合并回其父分支?我知道我能做到:

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/

相关文章:

git - 未知开关 'm' 与 git 别名提交

git - 使用 git hooks 为当前提交更改的每个文件创建差异报告

git - 如何编写一个以字符串作为参数的 git 别名

git - 设置使用 TR 将反斜杠转换为正斜杠的 Git 别名

Git 配置别名转义

Git:在所有子模块上递归切换分支( checkout )

bash - 如何制作检查提交消息的 git 预提交 Hook ?

git - 使用GIT部署网站

git - 创建 Git 标签时自动运行 Git 钩子(Hook)

java - Intellij Idea 无法执行 git pre-push hook