I try to clone my local git repository inside the pre-push script (client hook). I get the exception:
fatal: working tree '...' already exists.
I don't understand the exception, since i obviously clone the repo to a different directory.
Any ideas?
I tried that:
unset GIT_DIR
cd ..
git clone ./TestTest/ /tmp/PrePushTestClone
It fails exactly the same way :(
I had the same issue, except I was dealing with pre-commit
hook. When trying to clone
another repo inside the current repository there's an error with text something like:
fatal: working tree '.' already exists.
To fix this issue I had to add this line before clone
:
unset GIT_WORK_TREE
I have found this solution here: https://github.com/bower/bower/issues/1033
Happened to me too. I realized that I ran git clone
in a bash session opened from git rebase -i
that had GIT_DIR and GIT_WORK_TREE set in the environment.
Exiting the bash session resolved the issue...
since i obviously clone the repo to a different directory.
Your hook might consider $GIT_DIR
as referencing your current repo, which will interfere with a git clone
.
Make sure to:
unset GIT_DIR
in your pre-push scriptgit clone
in a folder outside your current repo folderIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With