Sublime Forum

SM keeps creating remote branches when I rename local branches?

#1

I have a repo with two remotes (one for the company I work for, one for our client). One remote is called github and the other is called origin. As you can see, each one should have 3 identical branches:

remotes

To make it easier to know which local branch I’m on, I’ve renamed the locals by doing right-click > rename [branchName]...

That way I know what I’m tracking:

REMOTE            LOCAL
origin/develop => originDevelop
github/develop => develop

locals

The problem is that when I push a commit from local originDevelop to remote origin/develop, it creates a new remote branch named origin/originDevelop. I never asked to create a new remote, it just does it automatically when I push!
newBranch

Is this a bug? How can I make local branch originDevelop track remote origin/develop without having it automatically create a new remote branch? Why does renaming a local branch automatically create a remote?

0 Likes

#2

This is standard git behaviour; the line git push origin develop tells git to push to the remote origin, and that it is pushing the develop branch. Git will update the branch on the remote or create it if it doesn’t exist.

In order to do do this you would need to invoke git push origin develop:originDevelop to tell git that the branch you’re using is named develop locally and originDevelop remotely.

I don’t think there’s a way to get Merge to do so directly though; you’re probably looking at a custom git alias that’s executed as part of a custom added command.

1 Like

#3

It’s backwards. The branch is named originDevelop locally and origin/develop remotely.

Anyway, glad to know this is default git behavior. I’ll just delete local branches that have the same name to avoid confusion.

1 Like