我在Windows 7下工作,我已经安装了msysgit和TortoiseGit。 我为git存储库编写了一个pre-rebase hook。
当我从Git Bash重新定位回购时,会调用该钩子。 但是,如果我从TortoiseGit启动rebase,则不会调用该钩子。 我尝试编写一个预提交钩子,它可以从bot Git Bash和TortoiseGit开始。
钩子如下:
#!/bin/sh
#
# Copyright (c) 2006, 2008 Junio C Hamano
#
# The "pre-rebase" hook is run just before "git rebase" starts doing
# its job, and can prevent the command from running by exiting with
# non-zero status.
#
# The hook is called with the following parameters:
#
# $1 -- the upstream the series was forked from.
# $2 -- the branch being rebased (or empty when rebasing the current branch).
#
# This sample shows how to prevent topic branches that are already
# merged to 'next' branch from getting rebased, because allowing it
# would result in rebasing already published history.
echo '************************************************************'
echo '********************** Running CMake **********************'
echo '************************************************************'
cmake -G "Visual Studio 11" -BBuild/ -Hsrc
怎么了?
答案 0 :(得分:1)
据我所知(使用git reflog
),TortoiseGit中的'rebase'并不真正执行真git rebase
。相反,TortoiseGit使用樱桃选择模拟一个rebase。
我不知道为什么,也许是为了让gui能够进行交互式变换?
无论如何,由于没有执行真正的rebase,因此不会运行与rebase相关的钩子。