Git over samba - unable to write sha1 filename | Permission denied
Asked Answered
C

7

14

When I am using git over samba share on windows I get an error when i want to commit a file via git_extentions or tortoiseGIT. The error is: error: unable to write sha1 filename .git/objects/b4/e819f886bf31b67c42249a0eff8e8b16cf7622: Permission denied. When I add the file via the ubuntu server and commit the file it works fine. I am also working in a banrch.

I have already tryed chmod 777 the whole .git folder.

Creamer answered 30/9, 2010 at 9:53 Comment(3)
What does the samba config file look like, and is the user the same as what git is expecting?Pallaton
This problem has just started occurring for me! I updated msysGit to v1.7.6.msysgit.0, but the server to which I connect to over the samba share to has v1.7.2.1 on. 1. I dont know which msysGit I had before to revert to to test. 2. so will upgrade the servers version to see if that helps.Wabble
Ok, that didnt help. v1.7.2.1 running on my server. This all started happening when I started using PortableGit for something else, and it happens with that as well!Wabble
W
5

I've seen this, too. It's a git defect, likely to do with how it creates and modifies files. To clarify the problem:

# mount a samba share locally. 
$ mount -t cifs options //share/project  /mnt/project

# The share contains a git checkout.
# Do some typical development.
$ cd /mnt/project
$ vi file    ## ok
$ git pull   ## ok
$ git status ## ok
$ git add file ## error!
  error: unable to create temporary sha1 filename 
  .git/objects/8b/tmp_obj_mYE1Xi: Permission denied


## But everything from the shell seems to work.
$ ls -latr .git/objects/8b/  ## ok. empty dir.
$ touch .git/objects/8b/tmp_obj_mYE1Xi ## ok.
$ echo test123> .git/objects/8b/tmp_obj_mYE1Xi ## ok.
$ cat  .git/objects/8b/tmp_obj_mYE1Xi  ## ok.
test123
$ rm  .git/objects/8b/tmp_obj_mYE1Xi  ## ok.

In git version 1.5.6.5 (latest Debian package), you get the error when you try to git-add. If you install git 1.7.3.2 (latest release), you can add the file, but you will get the error when you attempt to commit.

Wellgroomed answered 30/10, 2010 at 22:25 Comment(1)
Ahh, this is really annoying me! I only started getting this problem after either using PortableGit and/or upgrading mSysgit!Wabble
P
4

This issue has been seen before in some form or another for Git/Samba installations. Not sure if the source of the problem has been pin pointed yet:

http://code.google.com/p/msysgit/issues/detail?id=130#makechanges

Update:

looks like git v. 1.7.3.3 has resolved this issue.

Pallaton answered 1/11, 2010 at 23:35 Comment(4)
I actually updated samba as mentioned in the linked page, and it worked for me. code.google.com/p/msysgit/issues/detail?id=130#c21Greenlet
I am using v1.7.6.msysgit.0 and v1.7.2.1 on my server, but still see this!?Wabble
Still getting the issue on Git-1.9.5-preview20141217Cali
I get the issue on TortoiseGit 1.8, which uses Git 2.7.Soliz
W
3

Ok, I have found a solution that worked for me.

I have been using git over samba (samba-common-3.0.33-3.7.el5) for ages with no problems.

I upgraded git to Git-1.7.6-preview20110708, and it all went to pot!

As Im such a methodical developer, I didnt write down what I upgraded from!

So I went through the list of previous releases and saw a Star next to Git-1.7.0.2-preview20100309, so a bit old, but put that on.... and bang... it works!

Wabble answered 21/7, 2011 at 14:3 Comment(1)
Both links are now broken. And apt-get install git=1.7.0.2 yields Version '1.7.0.2' for 'git' was not found. What now?K
S
1

we started to use git today. version 1.7.10 was fine for win7 machines. on winXP we occurred the given error. for those machines we downgraded to 1.7.0.2 as Ian stated in his post and it works now.

Sergiosergipe answered 28/6, 2012 at 15:51 Comment(0)
C
0

Probably samba blocks dotfiles? Why not use ssh instead of samba for pushing?

Clarissaclarisse answered 30/9, 2010 at 10:6 Comment(2)
The dot files are not blocked and seen as hidden files in windows. How do you meen push by ssh? To commit the files via commandline is working fine.Creamer
I use git over samba because I develop on windows, but my test server is ubuntu. It means I do not have to deploy every time I want to test a change.Charyl
F
0

In my case it was the anti-virus software on Windows locking the file(s). Temporarily disabling the anti-virus fixed the problem.

Fennessy answered 25/9, 2013 at 14:28 Comment(0)
B
0

I answered this question over here as well

In my case, it looks like Git (v 2.6.3) tried to create its own read/write permissions on the Samba drive. This would prevent the pack files and/or objects from getting written (unpack error)

remote: error: unable to write sha1 filename ./objects/pack/pack-<some_hex_string>.pack: Permission denied
remote: fatal: cannot store pack file
error: unpack failed: index-pack abnormal exit
To z:\git\<repo name>
 ! [remote rejected] master -> master (unpacker error)
error: failed to push some refs

I went back and forth on trying to fix. Finally, since I had control of the Samba machine, I added a line to the samba drive config, which says "inherit permissions = yes". I restarted Samba and tried to push. It worked!

This worked for me since I'm the only person using the Samba server. For others, you may have the play around with "force directory mode" or "force create mode". You can find the man pages for those over here:

https://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/AccessControls.html

Brainwashing answered 14/12, 2015 at 5:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.