2

I am developing code on a Ubuntu VM, and have a Windows Repository on a common shared server my team uses.

Git is installed on the Ubuntu machine and not on Windows, currently.

I was receiving errors when trying to do a "git init" in Ubuntu on the Windows share folder so I created the folder in Ubuntu using "git init", then copied it to the folder that housed the project on the Windows server.

In Ubuntu, I did a git clone /run/user/1000/gvfs/smb-share:server..../Repos/demo_trunk/. successfully

I could make edits fine, commit fine but when I try to push OR pull my changes by way of something like "git push origin master", I get an error saying my share, /run/user/1000/gvfs/smb-share:server..../Repos/demo_trunk/. does not appear to be a git repository and could not read from remote repository. It also says, Please make sure you have the correct access rights and the repository exists.

I have already checked to ensure that when I do "git remote -v" that the smb server folder (/run/user/1000/gvfs/smb-share:server..../Repos/demo_trunk/.) exists.

Also, after making the change on my Ubuntu machine and running git status, the output says my branch is ahead of 'origin/master' by 1 commit, which seems to indicate it at least knows something changed in comparison to what is out on the Windows server.

I am at a complete loss and have Googled my head off trying to find a solution. It appears that it could be a permissions issue, but nothing has seemed to be specifically what I need.

Any advice would be most welcome.

5/26/2021

  1. Installed cifs

  2. Reinitialized the repo THROUGH the Ubuntu VM using the mounted drive created by cifs.

  3. Made edit, checked in edit on Ubuntu VM.

  4. Ran "git remote -v"

    origin /mnt/cifs/demo/. (fetch)

    origin /mnt/cifs/demo/. (push)

  5. Ran "git status"

    Your branch is ahead of 'origin/master' by 1 commit.

  6. Ran "git push origin master'

    Counting objects: 4, done.

    Delta Compression using up to 2 threads.

    Compressing objects: 100% (4/4), done.

    error: remote unpack failed: unable to create temporary object directory

    To /mnt/cifs/demo/.

    ! [remote rejected] master -> master (unpacker error)

    error: failed to push some refs to '/mnt/cifs/demo/.'

  7. Ran git push origin/master

    fatal: 'origin/master' does not appear to be a git repository

    fatal: 'Could not read from remote repository.

    Please make sure you have the correct access rights

    and the repository exists.

  8. I also ran a git reset --hard command (don't remember syntax)

    This successfully "reverted" back to what was out on the Windows share drive.

JWorkin
  • 31
  • 5
  • 1
    I would not use GVFS for Git operations. it provides some basic operations, but I don't think it provides a full set of POSIX behavior. Try using the Linux `mount.cifs` instead. – bk2204 May 25 '21 at 22:37
  • @bk2204 I'll try this in the morning. Do you think that would cause the issues I'm seeing? – JWorkin May 26 '21 at 00:34
  • 1
    I think it likely will. I've seen other people have problems with Git and GVFS in other situations, although I don't recall if it was SMB or SFTP. – bk2204 May 26 '21 at 00:59
  • @bk2204 added updates above. Let me know your thoughts! Thank you so much. – JWorkin May 26 '21 at 20:07
  • 1
    You don't have the proper permissions to create files on the remote repo, since you can't create a directory. – bk2204 May 26 '21 at 22:24
  • @bk2204 Is that still the case even though I can create folders on the Ubuntu cifs mnt(i.e. navigate to the mnt/cifs/demo/ folder and mkdir rmdir)? I'm able to see the folder get created/deleted on the windows side. – JWorkin May 27 '21 at 01:07
  • 1
    Well, you're unable to create the temporary directory, so it's either a permissions problem or some other type of problem, and my _guess_ is that it's permissions. – bk2204 May 27 '21 at 01:14
  • This solutions worked. Part of the issue was I need to run git push as sudo and cifs was necessary as you stated. – JWorkin Jun 10 '21 at 16:04

1 Answers1

0

I ran into this problem when mounting a cifs-share from a fritzbox.

I looked a bit under the hood, running strace -f git push and found that git was looking at the correct directory. But it failed to do something with the HEAD file, getting a Stale file handle-error as response.

...
stat64("/cifs/repo", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
lstat64("/cifs/repo/HEAD", {st_mode=S_IFREG|0755, st_size=23, ...}) = 0
openat(AT_FDCWD, "/cifs/repo/HEAD", O_RDONLY|O_LARGEFILE) = -1 ESTALE (Stale file handle)
...

As written here, adding the mount-option noserverino fixed my problem.

Chris
  • 5,788
  • 4
  • 29
  • 40