GIT can't pull: failed to symlink 'path/filename': File name too long

巧了我就是萌 提交于 2019-12-07 09:21:11

问题


Feeling silly, but I can't figure out what to do here.

I have a local copy of a repository stored on a remote server. The remote server has changes I need, and I've committed changes on my local copy. I can't push, because I need to merge the changes from the newer version that exists on the server. When I pull, I get this error:

 git pull origin master
 From server.name:reponame
  * branch            master     -> FETCH_HEAD
 fatal: failed to symlink 'path/to/filename ': File name too long

Not sure what would be happening here. The crazy thing is that the file path/to/filename is an actual file, not a symlink. Further, path/to/filename isn't even the longest path.

Really confused as to where to start debugging this problem.


回答1:


The only place where I see a failed to symlink is in the merge-recursive.c file:

if (S_ISLNK(mode)) {
  char *lnk = xmemdupz(buf, size);
  safe_create_leading_directories_const(path);
  unlink(path);
  if (symlink(lnk, path))
    die_errno(_("failed to symlink '%s'"), path);
  free(lnk);
} 

It looks like the remote repo you are pulling from contains filename as a symlink, while your local repo contains the same filename as a plain file.
That could be the cause of the fatal error message.




回答2:


I'd start debugging by beginning with git fetch and only after that succeeds, go for git merge. Presumably (as @VonC noted) the error will only happen with git merge (which makes sense since pull is just fetch-then-merge here). Since the fetch will have succeeded, you can inspect the commit(s) that cause the failing merge, and perhaps run the whole thing under strace or similar to observe the failing system call.

(The split into fetch+merge is not required, you can strace a pull, it's just that it should help reduce the amount of irrelevant crud to comb through.)

[Edit: and, once again SO has resurrected an old question... gotta start looking at the timestamps on these! And, noting the OSX tag, make that dtruss instead of strace.]




回答3:


I had the same problem but in my case I hadn't time to check how it would be happen. I resolved it by use command below - may be will be helpful for someone:

git config core.symlinks false

However, I don't know how this works for whole project, so you can use it for only your responsibility.



来源:https://stackoverflow.com/questions/12592948/git-cant-pull-failed-to-symlink-path-filename-file-name-too-long

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