Search code examples
gitsourcetree

SourceTree create local branch but do not push on remote


I would like to create local-only copy of our development branch. And once there are fixes on development branch, I would like to push those changes on remote and merge with my local branch as well.

The reason that I want this local branch, I have some experimental code over development branch and have some configuration values only for sandbox.

I created a new branch called "Local" and committed my changes. But once I hit push button, source tree wants to push them to remote, but I only want to keep them locally. (Do not create new branch over remote)

Is there any way to tell my local branch do not track remote, and only push to local if possible? Then there will be no pending changes for this branch (local one) as well.


Solution

  • Don't push.

    Pushing only has relevance or meaning on a remote repository; that implies that you wish for this branch to be published on the remote repository. This has the obvious advantage of it being in history and it being readily cloneable to another machine, but comes with the disadvantage of anyone really being able to clone it.

    If you don't want that behavior, then don't push the branch. Git will function just fine if you don't decide to push, with the main caveat being that you will have a harder time getting your work on another machine if you so desire.