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
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
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
.
Check that you do have a remote named origin, with a proper associated url
git remote -v
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
".
Usually after doing a git init and then also creating a repository in Github, the next thing I want to do is set my remote origin and tie my remote branch to my local master branch.
git init
git remote add origin <repository_url>
git fetch
Now, when I enter
git branch --set-upstream-to=origin/master master
I get the error: fatal: branch 'master' does not exist
So, I did a
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 this, git branch -a showed me the local master branch along with the remote,
master
remotes/origin/master
After this
git branch --set-upstream-to=origin/master master
gave no error and my local master branch was set to track the remote master branch.
I found this question while searching for
"fatal: branch 'integration/release/February' does not exist"
but the reason for the error in my case was different.
I "set upstream" enough that I'd made a bash alias for it, but when I tried to use the alias I introduced a space that meant the command I was sending was
git branch --set-upstream-to= integration/release/February
whereas what I needed, obviously, was
git branch --set-upstream-to=integration/release/February