我有一个 master 分支和一个 dev 分支用于当前开发(本地工作副本)。我需要将更改从 master merge 到我的 dev 分支。在 merge 之前,我运行了 git stash 并发现了以下错误:
fatal: Not a git repository (or any of the parent directories): .git
为了调查这个错误,我运行了以下命令:
git status
git branch
git remote -v
.所有产生相同的错误fatal: Not a git repository (or any of the parent directories): .git
我还尝试重置分支的起源 git remote set-url origin <a href="https://github.com/Connexions/oer.exports.git" rel="noreferrer noopener nofollow">https://github.com/Connexions/oer.exports.git</a>
产生相同的结果:fatal: Not a git repository (or any of the parent directories): .git
我也无法将本地工作目录中的任何更改提交到我的开发分支。
有没有人对如何解决这个问题有任何建议。
最佳答案
检查以下文件:
your_repo_dir/.git/HEAD
如果此内容看起来已损坏,这就是问题所在。我遇到了类似的问题,我通过将 HEAD 文件的内容替换为所选分支的最后一次提交的 git commit 哈希来修复它。
提交哈希可以在 .git/logs/refs/heads 和 branch_name_file
下找到
希望对你有帮助。
关于github 工作流程-致命的 : not a git repository (or any of the parent directories): . git,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12358162/