git:分支更改时快进切换的钩子?
是否有可用的钩子脚本可以在分支切换上进行快进合并?我有一个存储库,其中有多个分支,我必须在其中几个分支上工作。在 git pull 显然合并了当前签出的分支之后,我经常会在切换分支时看到以下消息:
> git checkout master
Switched to branch 'master'
Your branch is behind 'origin/master' by 10 commits, and can be fast-forwarded.
>
我希望 git 在分支更改时自动为我进行快进合并。我不希望它无条件合并,但仅当可以快进时才合并。
预先感谢您的建议,
朗达
Is there a hook script available somewhere that would do a fast-forward merge on branch switch? I have a repository where there are multiple branches, and I have to work on several on them. After a git pull which obviously merges the currently checked out branch it often happens to me that I see the following message when switching branches:
> git checkout master
Switched to branch 'master'
Your branch is behind 'origin/master' by 10 commits, and can be fast-forwarded.
>
I would like git to do that fast-forward merge for me automatically on branch change. I don't want it to unconditionally merge but only when a fast-forward is possible.
Thanks in advance for suggestions,
Rhonda
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议使用别名而不是挂钩,以便将
问题“当我希望我的分支始终更新时使用 Git”引用脚本“
git-fetch-and-fast-forward-all-branches.sh
”,这里可能很有趣。I would suggest an alias rather than a hook, in oder to combine:
git pull
The question "Using Git when I want my branches to be always updated" references the script "
git-fetch-and-fast-forward-all-branches.sh
", which can be of interest here.