Git - fatal: Could not get current working directory?

一世执手 提交于 2020-01-03 13:15:35

问题


When I git clone from a repo, I get,

fatal: Could not get current working directory: No such file or directory

What do I do? I have checked the server and found that .git file exists. The server is running a Gitlab instance. I have configured ssh properly with the keys, and I've been committing & cloning for a while now without any error, and this happens all of a sudden.

FWIW, I'm doing the git clone in a bash script.


Update

This is my bash script,

for repo in $repos
do
   git clone $repo /tmp/tmpdir/
   # do stuff with /tmp/tmpdir/
   rm -rf /tmp/tmpdir/
done

for the first repo it's fine, but when the for gets into the second repo it fails and gives the above fatal error.


回答1:


My guess is that somewhere in your do stuff section you change directory into /tmp/tmpdir/ so that in the next loop, the current working directory no longer exists. The fix is to change directory to /tmp/ (or anywhere really) before removing the /tmp/tmdir/ directory.




回答2:


In my case, this was caused by issuing a "git clone" from a subdirectory of a local git repo. I had to cd to another directory before I could clone the new repo.



来源:https://stackoverflow.com/questions/25138228/git-fatal-could-not-get-current-working-directory

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