Is "Push commits immediately" working fine when a local branch is tracking a remote branch with a different name?


Maybe I am wrong and this is the desired behavior, but I think the "Push commits immediately to" is not working fine when you have a local git branch tracking a remote branch with a different name.

In this case when you commit ant check the "Push commits immediately to" I was expecting that my commit will be pushed to the followed remote branch (remember with a different name than the local one), but instead a new remote branch is created with my local name at origin. Is this the expected behavior or is this a bug?



2 answers

1 accepted

0 votes
Accepted answer

I've recently started renaming my local branches to be more descriptive of which issue I'm tracking. When you commit, and then use the "Push immediately to..." function, it wants to create a remote branch with the same name. This is quite bad, as it has completely made me look like a noob the past couple days as I was committing away without first checking.

If you right-click on the branch in the sidebar, you can select the "Push to [...] (tracked)" option. It seems pretty inconsistent. At the very least there should be another checkbox in the commit window that allows us to choose to push to the tracked branch, or a branch named the same as our local branch.

To fix the issue so that the commit window always uses your tracked branch, you can go to

Preferences > Git > Set "Push branches" to "upstream"

This solves the problem.

I noticed also (at least now, not sure if this was also true with the latest sourcetree version when I posted the question) that you can be sure before the commit where the changes will be pushed because the message near the checkbox tells you...

Push changes immediately to branchName

And you can see that branch name changes from your local one to the remote one when changing the configuration like xaero indicated.

Thank you very much.

It is not working fine. For sure the most intuitive behavior is to push immediately to the tracked branch instead of creating another branch with the same name.

It's a very annoying bug indeed.

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...

1,123 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