Run command git branch --set-upstream - create an error

I tried to execute the command:

$ git branch --set-upstream-to master origin/master
fatal: branch 'origin/master' does not exist


I checked start / master exists


source to share

3 answers

Syntax git branch


git branch' (--set-upstream-to=<upstream> | -u <upstream>) [<branchname>]


In your case:

git branch --set-upstream-to=origin/master master 
# or
git branch -u origin/master master

# for git older than 1.8
git branch master --set-upstream origin/master


If you see an error like:

Error is: fatal: 
Cannot setup tracking information; starting point 'origin/master' is not a branch.


This means that you have not retrieved anything from the remote origin


  • Make sure you have a remote origin name with a matching url

    git remote -v

  • Try and select from source

    git fetch origin

You can learn more about the fetching process in After git update remote

new upstream branches are visible, but notorigin




I found this question by searching

"fatal: branch 'integration/release/February' does not exist"


but the reason for the error in my case was different.

I "set upstream" enough to create a bash alias for it, but when I tried to use the alias, I entered a space meaning that the command I was sending was

git branch --set-upstream-to= integration/release/February


whereas I needed obviously

git branch --set-upstream-to=integration/release/February




Usually after running git init and then creating a repository on Github, the next thing I want to do is install my remote origin and link my remote branch to my local master branch.

git init
git remote add origin <repository_url>
git fetch


Now that I enter

 git branch --set-upstream-to=origin/master master


I am getting error: fatal: branch 'master' does not exist

So I did

git branch -a 


and found only

remotes / origin / master

Since I was in a newly created git repository, I did a simple

git checkout master


After that, git branch -a showed me the local master branch along with the remote one.

  • master

    remotes / origin / master


git branch --set-upstream-to=origin/master master


gave no error and my local master branch was set to track the remote master branch.



All Articles