github 工作流程-致命的 : not a git repository (or any of the parent directories): . git

标签 git merge repository

我有一个 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/

相关文章:

ios - Zxing示例中的条形码扫描仪

git - `git reset stash` 的语义是什么?

zsh 中的 Git 选项卡完成抛出错误

Git Hook - 在我推送到 github 后让服务器 pull

sqlite - 在SQLite 3中合并行

Node.JS:使用多个 Git 存储库

git - 将远程 repo url 从 https 更改为 ssh 安全吗?

merge - 如何只 merge 一些文件?

git - 如何使用 git rebase 清理复杂的历史记录

c# - Entity Framework 4.1 的假 DbContext 来测试我的存储库