在git签出后钩子中,如何确定用户是否从头部分支?
我有一个签出后挂钩,如果用户只是这样做了,那么运行它就没有意义了:在git签出后钩子中,如何确定用户是否从头部分支?,git,Git,我有一个签出后挂钩,如果用户只是这样做了,那么运行它就没有意义了: git checkout -b somebranch 如何确定以前的分支是否指向与新分支相同的提交?git help hooks报告: post-checkout This hook is invoked when a git checkout is run after having updated the worktree. The hook is given three parameters:
git checkout -b somebranch
如何确定以前的分支是否指向与新分支相同的提交?
git help hooks
报告:
post-checkout
This hook is invoked when a git checkout is run after having updated the worktree. The hook is given three parameters:
the ref of the previous HEAD, the ref of the new HEAD (which may or may not have changed), and a flag indicating whether
the checkout was a branch checkout (changing branches, flag=1) or a file checkout (retrieving a file from the index,
flag=0). This hook cannot affect the outcome of git checkout.
请注意在签出已经完成后调用它的部分,以及它“不能影响git签出的结果”的部分
但是,它会传递上一个头部和新头部的参考值,因此您可以比较这些参考值,以查看您是否确实移动了,并根据该比较进行操作…Ah。。。RTFM!谢谢。看起来我想比较一下这些头,如果是分支结帐,我什么都不做,否则就做这些。