Elia Weiss
Elia Weiss

Reputation: 9856

SourceTree - fatal unable to create .git/index.lock file exists

Using SourceTree (on Mac), I often get fatal unable to create .git/index.lock file exists when I try to do any operation.

I'm pretty sure the cause is that my repository is old and big -

commits: git rev-list --all --count == 4660

files: git ls-files | wc -l == 8657)

It seems that any time I open the SourceTree window it run something to check status (probably git status) which takes more than 30 sec' and during this time, any action will result in fatal unable to create .git/index.lock file exists

Is there a way to disable SourceTree auto status check? I.e. run the status check manually - only when I need it.

Or

To do some kind of optimization on the git repo to make it more efficient?

Upvotes: 3

Views: 1362

Answers (2)

evry.one
evry.one

Reputation: 74

Most answers says to run the "rm index.lock" script, but somehow it didn't work for me this time. Terminal kept returning

rm: cannot remove './.git/index.lock': Device or resource busy

This seems to be a Sourcetree issue, and I finally found a solution:

In Sourcetree: Open Tools > Options > Git and Switch to Embedded Git. If you try to push it fails (for me at least).

Go back again and switch back to System Git and now when you push it actually works (for me at least :))

Upvotes: -1

S.Spieker
S.Spieker

Reputation: 7355

Have you verified this with the Process Log?

From SourceTree Blog:

We began by adding the Process Log, which helps you clearly understand how Sourcetree is using Git and Mercurial. It can also help diagnose issues like long-running, orphaned or duplicate processes. It’s also for those who might be curious about how things work behind-the-scenes without opening Task Manager or a terminal window to dig deeper. Using this new utility we were able to identify and resolve a number of subtle bugs that were unexpectedly consuming precious computing resources.

process log

But in case you want to disable it anyway:

Auto-refreshing should only occur if some other application is changing files in your repository, because SourceTree refreshes in response to events from the operating system. Is there something this is frequently saving files in your repository, triggering the refresh?

You can disable auto-refreshing in SourceTree either for a single repository (Settings on the toolbar, Advanced, disable auto-refresh checkbox), or you can do it globally in Preferences (or Tools > Options on Windows), the same Auto-refresh when files change option.

Once auto refresh is disabled use:

CTRL+ALT+R Refresh remote status on windows

CMD+R Refresh remote status on mac

Upvotes: 2

Related Questions