Git“无法确定git目录的绝对路径”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11539076/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git "unable to determine absolute path of git directory"
提问by Matt Parkins
I'm a git newbie and am having problems trying to get the latest version of a remote project:
我是 git 新手,在尝试获取远程项目的最新版本时遇到问题:
S:\dev\prj\myprj [master]> git pull
/usr/libexec/git-core/git-sh-setup: line 266: cd: .git: No such file or directory
Unable to determine absolute path of git directory
It was working fine until today and strangely I don't think I've changed anything since it last worked fine.
直到今天它都运行良好,奇怪的是,自从它上次运行良好以来,我认为我没有改变任何东西。
This is on Windows 7. My project is on an encrypted drive (S:) and git is on C:
这是在 Windows 7 上。我的项目在加密驱动器 (S:) 上,而 git 在 C:
S:\dev\prj\myprj [master]> git --exec-path
C:\Users\matt\AppData\Local\GitHub\PortableGit_656cc1ef6d04f06ddf8b2f5bedbac921caed3b62/libexec/git-core
Manually doing a cd to the exec directory above works fine (even though there are mixed slash types).
手动对上面的 exec 目录执行 cd 工作正常(即使有混合斜杠类型)。
Any ideas how to even start working out what has gone wrong?
任何想法如何开始弄清楚出了什么问题?
采纳答案by Matt Parkins
Found the solution/workaround! Hurrah!
找到解决方案/解决方法!欢呼!
I was (and still am) using GitHub for Windows, and occasionally it asks me to go to Windows Powershell to fix the repository because sometimes it can't do it automatically, and occasionally it would fail with the above error message.
我曾经(现在仍然)使用 GitHub for Windows,偶尔它会要求我去 Windows Powershell 修复存储库,因为有时它不能自动修复,有时它会失败并显示上述错误消息。
The reason it was failing for me was not just that my project was on an encrypted drive but, more importantly, that sometimes I would start GitHub for Windows before mounting the encrypted drive (which I manually mount). Even if I then close GitHub for Windows, then mount the encrypted drive, and then relaunch GitHub for Windows it would still come back with the above error, so perhaps not everything GitHubby is being shut down when I close GitHub for Windows.
对我来说它失败的原因不仅是我的项目在加密驱动器上,更重要的是,有时我会在安装加密驱动器(我手动安装)之前启动 GitHub for Windows。即使我随后关闭 GitHub for Windows,然后安装加密驱动器,然后重新启动 GitHub for Windows 它仍然会返回上述错误,因此当我关闭 GitHub for Windows 时,可能并非所有 GitHubby 都被关闭。
The workaround for me is to:
我的解决方法是:
- Reboot
- Mount Drive containing project
- Launch GitHub for Windows
- 重启
- 安装包含项目的驱动器
- 启动 Windows 版 GitHub
...in that order.
...以该顺序。
回答by Nikolaos Georgiou
Killing the ssh-agent.exeprocess works for me.
Note: It is called sh.exein newer versions of SourceTree (thanks @cowlinator)
杀死ssh-agent.exe进程对我有用。
注:这就是所谓sh.exe在SourceTree的新版本(感谢@cowlinator)
回答by Ana Betts
You're most likely using PowerShell and a mapped network drive. PowerShell "helpfully" undoes the mapping, so the directory passed to Git is a UNC path which Git doesn't understand.
您很可能正在使用 PowerShell 和映射的网络驱动器。PowerShell“帮助”撤消了映射,因此传递给 Git 的目录是 Git 无法识别的 UNC 路径。
回答by Mi?a Pei?
If you are using SourceTree on Windows, try Tools- > Options -> Git -> Use system Git
如果您在 Windows 上使用 SourceTree,请尝试工具-> 选项-> Git -> 使用系统 Git