git 使用终端和 MacFusion 时出现 GIT_DISCOVERY_ACROSS_FILESYSTEM 问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7116015/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 11:37:30  来源:igfitidea点击:

GIT_DISCOVERY_ACROSS_FILESYSTEM problem when working with terminal and MacFusion

gitsshsshfsmacfuse

提问by Ribena

I'm using MacFusion with OSXFuse(similar to MacFuse) to mount my server over SSH onto my office machine. When I cd into my rails work directory on the server, i can't see any git info in my zsh prompt. If i try a git pull origin, i get the following error message:

我正在使用 MacFusion 和 OSXFuse(类似于 MacFuse)通过 SSH 将我的服务器安装到我的办公室机器上。当我 cd 进入服务器上的 rails 工作目录时,我在 zsh 提示符中看不到任何 git 信息。如果我尝试 git pull origin,我会收到以下错误消息:

fatal: Not a git repository (or any parent up to mount parent /Volumes)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set)

I know I can ssh to the server but then wouldn't I lose zsh autocorrection & history? Wouldn't I also need to set up textmate and other software to use ssh? And wouldn't I need to remote desktop to install DMG's and so on? All of that seems like a bit of a hassle.

我知道我可以通过 ssh 连接到服务器,但是我不会丢失 zsh 自动更正和历史记录吗?使用ssh是不是还需要设置textmate等软件?我不需要远程桌面来安装 DMG 等等吗?所有这些看起来都有些麻烦。

Is there a better way to do what I want to do? Otherwise is there a way to enable GIT_DISCOVERY_ACROSS_FILESYSTEM?

有没有更好的方法来做我想做的事情?否则有没有办法启用 GIT_DISCOVERY_ACROSS_FILESYSTEM?

PS - MacFusion can also mount the server over FTP - would that be preferable to SSH?

PS - MacFusion 也可以通过 FTP 挂载服务器 - 这比 SSH 更可取吗?

采纳答案by Lily Ballard

Are you ssh'ing to a directory that's inside your work tree? If the root of your ssh mount point doesn't include the .git dir, then zsh won't be able to find git info. Make sure you're mounting something that includes the root of the repo.

您是否通过 ssh 连接到工作树中的目录?如果 ssh 挂载点的根目录不包含 .git 目录,则 zsh 将无法找到 git 信息。确保您正在安装包含 repo 根目录的内容。

As for GIT_DISCOVERY_ACROSS_FILESYSTEM, it doesn't do what you want. Git by default will stop at a filesystem boundary. If you turn that on (and it's just an env var), then git will cross the filesystem boundary and keep looking. However, that's almost never useful, because you'd be implying that you have a .git directory on your local machine that's somehow meant to manage a work tree that's comprised partially of an sshfs mount. That doesn't make much sense.

至于 GIT_DISCOVERY_ACROSS_FILESYSTEM,它不会做你想要的。默认情况下,Git 将在文件系统边界处停止。如果你打开它(它只是一个环境变量),那么 git 将跨越文件系统边界并继续寻找。但是,这几乎没有用,因为您暗示您在本地计算机上有一个 .git 目录,该目录以某种方式用于管理部分由 sshfs 挂载组成的工作树。那没有多大意义。

回答by Kirkland

I got this error until I realized that I hadn't intialized a Git repository in that folder, on a mounted vagrant machine.

我收到这个错误,直到我意识到我没有在安装的流浪机器上的那个文件夹中初始化 Git 存储库。

So I typed git initand then git worked.

所以我打字git init,然后 git 工作。

回答by Dror

You will also get this if git doesn't have permissions to read the config files. It will just go up in the hierarchy tree until it needs to cross file systems.

如果 git 没有读取配置文件的权限,你也会得到这个。它只会在层次结构树中上升,直到它需要跨文件系统。

回答by M.C.

My Problem was that I was not in the correct git directory that I just cloned.

我的问题是我不在刚刚克隆的正确 git 目录中。

回答by BF4

Coming here from first Google hit:

从第一次谷歌命中来到这里:

You can turn off the behavior AND and warning by exporting GIT_DISCOVERY_ACROSS_FILESYSTEM=1.

您可以通过导出来关闭行为 AND 和警告GIT_DISCOVERY_ACROSS_FILESYSTEM=1

On heroku, if you heroku config:set GIT_DISCOVERY_ACROSS_FILESYSTEM=1the warning will go away.

在heroku上,如果你heroku config:set GIT_DISCOVERY_ACROSS_FILESYSTEM=1警告就会消失。

It's probably because you are building a gem from source and the gemspec shells out to git, like many do today. So, you'll still get the warning fatal: Not a git repository (or any of the parent directories): .gitbut addressing that is for another day :)

这可能是因为您正在从源代码构建一个 gem,并且 gemspec 将 shell 扩展到git,就像今天许多人所做的那样。因此,您仍然会收到警告,fatal: Not a git repository (or any of the parent directories): .git但要改天再解决:)

My answer is a duplicate of: - comment GIT_DISCOVERY_ACROSS_FILESYSTEM problem when working with terminal and MacFusion

我的回答是重复的: -使用终端和 MacFusion 时评论GIT_DISCOVERY_ACROSS_FILESYSTEM 问题

回答by Bruce

Try a different protocol. git:// may have problems from your firewall, for example; try a git clone with https: instead.

尝试不同的协议。例如,git:// 可能有防火墙问题;尝试使用 https: 进行 git clone。