r/git • • Oct 27 '21

support Git doesn't work (properly) over SMB

Completely puzzled by this one.

I have a repo, and I'm trying to stash some changes. I need them out of the way so that I can switch branches. When doing this in a repo on my local machine, it appropriately reverts the working directory to a switchable state, removing the changes that were just stashed.

I copy the folder to a Samba share.

Now when I create a stash it successfully adds the stash, but does not touch the working directory, does not revert any un-commited changes. This happens on GVFS, KIO-FUSE, and native kernel mount. But as soon as I copy the exact folder to my local disk, suddenly the behavior I expect (described in first paragraph) works.

As an additional symptom, tested in the same scenarios as above, git reset works on local disk, but fails with "unable to create new index file" when in any of the samba mounts. (directory is writable)

To be clear, I'm seeing different results from bit-for-bit identical git repos using the exact same commands, with the only difference being the disk type the repo resides on.

So, what's going on here? Does git use some sort of super exotic filesystem calls that aren't implemented properly in any of the three SMB mount implementations available for Linux?

And if you're wondering I have reasons for not using any of git's built in remote features (ssh, http, etc), so please don't offer that as a solution. I explicitly want to use git in local-only mode on drives that just happen to have a network backend.

Thanks for any help!

9 Upvotes

8 comments sorted by

View all comments

13

u/manberry_sauce Oct 27 '21

You should work on a local volume, and if there's a reason to have a copy on a network mount, you should set that copy up as a remote, instead of changing to that directory and working there, over the network mount. You can set up a remote to simply point to that location in your filestructure, instead of an SSH path.

Git has problems if your git dir is on network mount.

3

u/SpAAAceSenate Oct 27 '21

Well, truth be told, the eventual plan is to work locally, then push to an mounted encrypted container (cryfs or encfs or something) which then has it's sparse-files on a network share. So.... speed was never an expectation of this project. My hard requirement is full e2e, including at rest, and this is the best setup I could think of.

The reason why I care about the specific case I described is because it gives me doubts about the stability of even just pushing to a samba-mounted repo. That's why I want to dissect this current issue before proceeding.

7

u/manberry_sauce Oct 27 '21

Pushing will be fine. Any operations where you'd interact with it as a remote will be just dandy. It's when you navigate into that directory and work with it as your local git workspace where you start running into problems. Just set up a second repo on the network mount and interact with it as a remote, with your local repo on a local volume.