I use the following hook after taking:
GIT_TOP=`git rev-parse --show-toplevel` while read oldrev newrev refname do echo "=== $oldrev" echo "=== $newrev" echo "=== $refname" echo "=== 01. checkout -- $GIT_TOP/*" git checkout -- "$GIT_TOP/*" echo "=== 02. merging $refname" git merge $refname echo "=== 03. checkout -- $GIT_TOP/*" git checkout -- "$GIT_TOP/*" done
The idea is clear enough: I want the current branch to be merged with the pressed one.
Then I execute: git status , and it shows me that my local tree is different from the branch!
The more I do git checkout -- * at the top of git dir - and now this command does what I want: git status no longer shows the differences.
Why did this git checkout -- "$GIT_TOP/*" command git checkout -- "$GIT_TOP/*" not work and only work with a direct call? How to run this command in hook?
PS
I found that git rev-parse --show-toplevel , called from inside the hook, returns the path <myrepo>/.git , but from the shell its value is <myrepo> . Perhaps this will help solve the problem.
egor7 source share