Unable to add using SourceTree


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


3 answers

1 accepted

0 votes
Accepted answer

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.

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.


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
Community showcase
Published Oct 23, 2018 in Sourcetree

Tip from the team: configure your repos for hosting goodness!

Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...

960 views 4 2
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you