To set the upstream branch of your current branch back to origin/master
,
use the -u|--set-upstream-to
option of git branch
:
git branch -u origin/master
The -u
flag you passed to git push
instructed git to link your current branch to remote branch origin/01-MyfeatureProductListing
. git branch -u
allows you to override this to any remote branch you want.
You can also use --unset-upstream
to stop having git compare your local branch with a remote branch.
You can view the links between local branches and remote branches in the .git/config
file of your local clone ; if you open this file with any text editor (gedit, notepad, vscode ... ), you should see several sections looking like :
[branch "mybranch"]
remote = origin
merge = refs/heads/01-MyfeatureProductListing
The above means local branch mybranch
is set up to track origin/01-MyfeatureProductListing
.
The -u
option simply updates this section.
[edit] obviously : the -u
option to git push
is completely optional, if you want to push without setting or updating the remote tracked branch, just drop the -u
option ...