I have only master branch on my remote origin.
Then I did:
git fetch origin refs/heads/master:refs/remotes/origin/master2
as a result I got:
* [new branch] master -> origin/master2
which seems all right.
It is shown as remote tracking branch with the master:
bash$ git branch -r
origin/HEAD -> origin/master
origin/master
origin/master2
but master2 is shown as :
bash$ git remote show origin
Remote branches:
master tracked
refs/remotes/origin/master2 stale (use 'git remote prune' to remove)
I. My first question is why master2 is shown as stale? I was able to fetch to it (and create it as my local remote tracking one) and I would expect that it will be mapped to remote origin/master?
II. Second question is why I have to do:
bash$ git branch -r -d origin/master2
to delete it and got error when trying to do it by giving full refspec:
bash$ git branch -r -d refs/remotes/origin/master2
error: remote-tracking branch 'refs/remotes/origin/master2' not found.
I've checked man of git-branch and found there nothing special about branch name:
<branchname>
The name of the branch to create or delete. The new branch name
must pass all checks defined by git-check-ref-format(1). Some of
these checks may restrict the characters allowed in a branch name.