Git “unable to determine absolute path of git directory”

≯℡__Kan透↙ 提交于 2019-12-29 07:22:40

问题


I'm a git newbie and am having problems trying to get the latest version of a remote project:

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:

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).

Any ideas how to even start working out what has gone wrong?


回答1:


Killing the ssh-agent.exe process works for me.
Note: It is called sh.exe in newer versions of SourceTree (thanks @cowlinator)




回答2:


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.

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.

The workaround for me is to:

  1. Reboot
  2. Mount Drive containing project
  3. Launch GitHub for Windows

...in that order.




回答3:


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.




回答4:


If you are using SourceTree on Windows, try Tools- > Options -> Git -> Use system Git



来源:https://stackoverflow.com/questions/11539076/git-unable-to-determine-absolute-path-of-git-directory

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!