Why does SourceTree connect to a remote repository when I commit locally?
Asked by mattneub:

When I do a local commit in git using SourceTree, I can see (from LittleSnitch) that SourceTree communicates with a remote repo. But why? I'm not asking to push while committing (and in any case this isn't even a tracked branch; I'm trying to work completely locally). This feels like a bug.


Answers:
author: KieranA
body: Hi Matt,

I've created an issue for this on JIRA: <https://jira.atlassian.com/browse/SRCTREE-1684>. I'll be doing some more thorough checks on this one and fixing it upon findings.

Cheers

comments: author: mattneub
body: Thanks, Kieran! In the meantime I've used Steve's hint to turn off background remote checking for all my repositories individually.


author: stevestreeting
body: It's actually not related to the commit, but the periodic remote refresh (Fetch in git, incoming/outgoing in hg) SourceTree uses to display up-to-date pending markers for push/pull. By default this runs every 10 minutes, it must just have kicked in at a similar time.

If you'd prefer it didn't do this, you can disable it per repository (Settings in the toolbar \> Advanced \> Refresh remote status in the background), or globally for all repositories (Tools \> Options \> Check default remotes for updates every X minutes)

comments: author: stevestreeting
body: That's assuming you don't have the 'Push immediately' option enabled in the commit dialog BTW, which would obviously communicate with the remote - but that's disabled by default).


author: mattneub
body: Thanks, Steve! I couldn't find Tools \> Options, but I can find Preferences \> General, and "Check default remotes" is \*unchecked\*. I think I would intuitively expect that since this a global preference, individual repositories would just obey it.

The repository setting for (Toolbar) Settings \> Advanced \> "Refresh remote status in the background" is \*checked\*, but that checkbox also says "if enabled in global preferences", and it isn't. So again, this feels like a bug. I am not doing anything that should involve communication with the remote repo. I'll try unchecking it and see if that helps. Thx.


author: stevestreeting
body: Sorry, I was talking about the Windows version - yes it's in Preferences on Mac. So yes if the global 'check default remotes' is unchecked it shouldn't be this.

Can you reproduce it whenever you commit? We definitely don't attempt to do anything with the remote when you commit unless you check the Push Immediately box, but maybe there's a refresh that's happening afterwards that is querying the remote by accident - I would have thought we would have noticed that before since remote checking always slows things down, so we try to avoid it at all costs, but if you observe it every time w can check a bit deeper.


author: mattneub
body: I may be wrong about \*when\* SourceTree is connecting to the remote repo, but I am not wrong that it \*is\* doing so. It definitely is doing so. LittleSnitch tells me so. For example, I just launched SourceTree, and the bookmarks window opened - and SourceTree connected to the remote repos of both of them (one is at github, the other is held by O'Reilly), even though "Check remote defaults" is \*unchecked\* in the preferences.

Thus I suggest that there \*is\* a bug and that you \*should\* dig deeper. I will turn off "Refresh remote status in the background" on a repo-by-repo basis and see if it makes a difference, but the point of a global preference, if it is working like a global preference, is that I should not have to.

(You say, by the way, "we would have noticed that before since remote checking always slows things down, so we try to avoid it at all costs". I would answer, yes, indeed, it is the very fact that SourceTree does certain things so slowly, such as launching, opening a repo window, and committing, that got me thinking about this issue.)