42

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:

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.

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

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

Ribena
  • 1,086
  • 1
  • 11
  • 20
  • 9
    I just got the same error message because I typed `git checkout /my/repo.git repo` instead of `git clone /my/repo.git repo`. Damn old SVN habits! – Frank Nov 19 '12 at 17:46

6 Answers6

30

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

So I typed git init and then git worked.

Kirkland
  • 3,257
  • 1
  • 16
  • 17
29

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.

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.

Lily Ballard
  • 182,031
  • 33
  • 381
  • 347
  • 1
    Cheers. That was indeed the problem. As I had copied the directory to the server, .git was not present in the repo. All working fine after a git clone instead. Is what I'm doing a bad idea for any reason? Is there a better way to go about this? – Ribena Aug 19 '11 at 03:03
  • 2
    @Ribena: Using a git repo on an sshfs mount should be perfectly fine. But yeah, copying your git repo manually instead of doing a git clone isn't generally a great idea. – Lily Ballard Aug 19 '11 at 05:51
  • 1
    I love the principle of every `clone`d repo being independent, sync'd via `pull` and `push`. I can imagine circumstances when I might want to keep two copies of the same repo in sync. Then I would use `rsync(1)` instead of `cp(1)`. Then I would get tired of that and go back to using `clone`, `pull`, and `push`. :) – tbc0 Apr 16 '15 at 20:15
  • This may cause issues for docker containers that are mounting volumes. – carter Nov 14 '17 at 05:05
3

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.

Dror
  • 2,370
  • 1
  • 18
  • 13
  • Great point -- so setting GIT_DISCOVERY_ACROSS_FILESYSTEM=1 will not solve it in that case. Creating a new ext4 drive in Fusion and doing the pull onto that volume solved it. – Brent Faust Dec 20 '13 at 06:47
  • On the Windows subsystem for Linux I had to `sudo chmod -R +777 .git` in the folder to get it to work. – Max Candocia Aug 08 '18 at 13:56
2

Coming here from first Google hit:

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

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

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): .git but addressing that is for another day :)

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

BF4
  • 1,076
  • 7
  • 23
1

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

M.C.
  • 1,765
  • 3
  • 29
  • 31
0

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

Bruce
  • 199
  • 2
  • 2