You have 2 options:
1 / Make a push to create the remote branch, then create the missing link:
git push origin master
2 / Break local binding between master
and origin/master
:
git branch --unset-upstream
The consequence of this is that in git fetch|pull|push
, you will have to manually specify the local branch parameters and the remote branch to make the connection. Also, git status
will no longer show the divergence between the local and remote branch.
To summarize, --unset-upstream
only deletes a link locally, without erasing any data. You can then re-connect at any time:
git branch master --set-upstream-to=origin/master
Generally
When you create a remote repository ( git init --bare
), it does not have any branches, but when you clone the remote in a local repository, the master
branch has an upstream link with origin/master
, even if origin/master
does not yet exist. Example:
# Criação d'um repository remoto
$ mkdir remote.git && cd remote.git && git init --bare && cd ..
Initialized empty Git repository in /tmp/remote.git/
# Criação de um clone locale
$ git clone remote.git local && cd local
Cloning into 'local'...
warning: You appear to have cloned an empty repository.
done.
# Criação do primeiro commit, necessario para ter um 'git status' normal.
$ echo "txt" > file.txt && git add file.txt && git commit -m "Initial commit"
# A mensagem vá aparecer
$ git status
On branch master
Your branch is based on 'origin/master', but the upstream is gone.
(use "git branch --unset-upstream" to fixup)
nothing to commit, working directory clean
# Verificando a ligacao 'master' -> 'origin/master'
$ git branch -vv
* master 8cbd8af [origin/master: gone] Initial commit
In your case, you have made other modifications, perhaps mistakes. First, it updates the data from the remote repository:
git fetch origin
It checks which remote branches it has in the remote repository, and checks the connections:
git remote show origin
git branch -vv
If you have created a bad branch, you can delete it with (example with branch test
):
git push origin :test