Unable to add using SourceTree

Jun Cho June 30, 2013

Hello

I'm getting the following error message when I try to add file(s) using SourceTree.

git -c diff.mnemonicprefix=false -c core.quotepath=false add -f -- readme.txt

warning: LF will be replaced by CRLF in readme.txt.

The file will have its original line endings in your working directory.

error: unable to write sha1 filename .git/objects/1c/18a9e638b2dea1aa7c81bf21900faef855bc0d: Permission denied

error: readme.txt: failed to insert into database

error: unable to index file readme.txt

fatal: adding files failed

I'm using BitBucket and there is a private repository and trying to commit and push.

As a first time user of Git, BitBucket and SourceTree, I might have made a mistake but can't find what the problem is.... Any help or tip would be appreciated.

Many thanks in advance

Jun

3 answers

1 accepted

0 votes
Answer accepted
Ian Chan July 1, 2013

I ran into this error when some items in the .git/objects folder were owned by root rather than my user account. In other words, you might check the permissions on that folder.

1 vote
Jun Cho July 1, 2013

Thanks guys.

I first had a go Ian's suggestion as it looked a bit easier to try and the error seems came from the permission issue.

Just for other people who might hit the same problem.

I use Windows and the server, where all my works are, is running on Mac. Although I had set the folder permission as read&write, SourceTree was still not able to save(write) to the folder. So that I recreated a folder on my computer(local machine) and it just worked!

I now know what caused the issue and will need to speak to a network manager.

Cheers~!

0 votes
KieranA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 1, 2013

Hi Jun,

This is a result of something going wrong with Git rather than SourceTree. This issue has been highly reported and the solutions are varying. One simple solution is to recursively chmod your repository folder to the user that's going to be committing. This is provided that user should have access to the various files. You can issue the following command:

chmod -R 644 <dir>

Make sure this is run from the project directory. If this doesn't work then we can look at alternate solutions from there.

Hope that helps

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events