Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run command git branch --set-upstream-to produce error

Tags:

git

I tried to execute command:

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

I checked origin/master exists

like image 413
Sergii Bezgin Avatar asked Oct 09 '14 15:10

Sergii Bezgin


1 Answers

The syntax for git branch is:

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.

It means you haven't fetched anything from the remote origin.

  1. Check that you do have a remote named origin, with a proper associated url

    git remote -v
    
  2. Try and fetch from origin

    git fetch origin
    

You can see more about the fetch process in "After git update remote the new upstream branches are visible but not origin".

like image 88
VonC Avatar answered Oct 23 '22 19:10

VonC