Unable to add using SourceTree

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

This widget could not be displayed.

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.

This widget could not be displayed.

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~!

This widget could not be displayed.

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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Published May 30, 2018 in Sourcetree

Tip from the team: configuring Git or Mercurial in Sourcetree

Supported Platforms macOS Windows To make using Sourcetree as simple yet powerful as possible we embed (bundle) dependencies such as Git, Git LFS, and Mercurial. We strive to keep these...

731 views 1 3
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