git - 在预推 Hook 中克隆 GIT 存储库时出现异常 "working tree already exists"

标签 git clone githooks git-push

我尝试在预推送脚本(客户端 Hook )中克隆我的本地 git 存储库。我得到异常:

fatal: working tree '...' already exists.

我不明白这个异常(exception),因为我显然将 repo 克隆到不同的目录。

有什么想法吗?


我试过了:

unset GIT_DIR
cd ..
git clone ./TestTest/ /tmp/PrePushTestClone

它以完全相同的方式失败:(

最佳答案

我有同样的问题,除了我正在处理 pre-commit 钩子(Hook)。当尝试在当前存储库中克隆另一个存储库时,出现类似文本的错误:

fatal: working tree '.' already exists.

为了解决这个问题,我必须在 clone 之前添加这一行:

unset GIT_WORK_TREE

我在这里找到了这个解决方案:https://github.com/bower/bower/issues/1033

关于git - 在预推 Hook 中克隆 GIT 存储库时出现异常 "working tree already exists",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34224729/

相关文章:

jQuery 克隆没有 id 的元素

jquery - 将 div 克隆到 obj 中并对其进行操作

git - 从 git 预提交 Hook 运行时 `git diff` 不起作用

GIT:删除没有本地跟踪分支的远程分支

git - 推送或克隆存储库时 .gitignore 的隐私?

git - 如何在 git repo 中添加缺失的 origin/HEAD

linux - 如何在停止状态下 fork Linux 进程?

git - 在 git push 上跳过 githooks

git - 验证提交是否存在

git - 如何取消提交 Git 更改