0

lets say I have 2 branches 1. BranchOne 2. master - his remote branch is origin/master

I tried to make the remote of BranchOne to be also origin/master but it doesnt let me and it gives me the option to create a remote origin/BranchOne and then make a pull request Is it not possible to set both local branches upstream to the same remote ?

MD10
  • 1,313
  • 3
  • 12
  • 35
  • 3
    The only restriction on `git branch --set-upstream-to= ` is that both `` and `` must exist in the local Git repository. Show your actual commands and error messages (cut and paste the text of the commands). See [ask] and [mcve] – torek Dec 22 '19 at 23:15
  • I am on my local branch want the origin of it to be origin/master git branch --set-upstream-to origin master Branch 'master' set up to track remote branch 'master' from 'origin' However when I push it created a remote branch which is named my localBranch name – MD10 Dec 22 '19 at 23:37
  • The upstream setting of a branch has relatively little to do with the push action. Your set-upstream-to operations have worked; it looks like you've asked the wrong question. – torek Dec 22 '19 at 23:41
  • I want to push the local branch to origin/master and not create a remote branch named local branch name.. what do I need to do ? – MD10 Dec 22 '19 at 23:44
  • It looks like the question you intended to ask is [this one](https://stackoverflow.com/q/13751319/1256452). – torek Dec 22 '19 at 23:46
  • @torek had it correct except for a small change in command. `git branch --set-upstream-to=origin/master` It should be `--set-upstream-to=origin/master` instead of `--set-upstream-to=origin master` That should do the trick. Please note that after this all pull and push will happen on master of remote. – Vishwanath Dec 24 '19 at 11:56
  • @Vishwanath: based on his comments, his example command was just an example: none of these branches are actually named `master` so therefore that is not the actual `git branch --set-upstream-to=...` command he typed in. In any case the issue is with the *push* operations. Git 2.x defaults to `push.default` set to `simple`. MD10 must have it set to something else, such as `current`, or be using a Git version predating 2.0. – torek Dec 24 '19 at 12:02
  • Thats some new learning for me. Thanks for that. I just tried the command and realised that having space in the upstream value creates the issue; then tried it with slash for upstream value on my local repo as a test. That worked as expected. Thinking he might have got the same issue so tried clearing that confusion. – Vishwanath Dec 24 '19 at 12:09

0 Answers0