The list of actions I do and the result:
Locally I have a master
branch and I have it on a remote.
I create a dev/test
branch locally
I push it to the remote
On the Azure DevOps website I can see that branch appeared in Branches in the "Mine" tab.
If I try to fetch and list branches from Visual Studio or git bash only the master
branch is visible.
$ git branch -r
origin/HEAD -> origin/master
origin/master
The only way I found to show all remote branches is:
$ git ls-remote --heads origin
08e2d2e3d332b607cef7cc85068b7eb1459d6d82 refs/heads/dev/test
04465a9f213757430aea00b77c4841c2e35ec8dc refs/heads/master
The problem is that I cannot checkout/pull/merge the branch that I don't see.
I tried to create a new repository and do the same actions, everything is visible as usual and as it should be. So the issue only with a specific repository.
My question is, what should I check? How to make the remote branch visible?
Actions I tried:
git fetch
does absolutely nothing.
$ git branch -vv
* dev/test ada4e0e commmitMessage
master ada4e0e [origin/master] commmitMessage
It doesn't show remote tracking, I tried to add it
$ git branch -u origin/dev/test
error: the requested upstream branch 'origin/dev/test' does not exist
hint:
hint: If you are planning on basing your work on an upstream
hint: branch that already exists at the remote, you may need to
hint: run "git fetch" to retrieve it.
hint:
hint: If you are planning to push out a new local branch that
hint: will track its remote counterpart, you may want to use
hint: "git push -u" to set the upstream config as you push.
So I did what was suggested
$ git push -u
Everything up-to-date
Branch 'dev/test' set up to track remote branch 'dev/test' from 'origin'.
And checked again
$ git fetch
From https://dev.azure.com/company/repo/_git/repo
* branch dev/test -> FETCH_HEAD
$ git branch -vv
* dev/test ada4e0e commmitMessage
master ada4e0e [origin/master] commmitMessage
$ git branch -r
origin/HEAD -> origin/master
origin/master
I found out the solution. The repository was connected via HTTPS.
Switching to SSH solved all the issues.
The step by step instruction in microsoft docs.
Step 1
In Bash:
$ ssh-keygen -C "your@email.com".
Step 2
Add public key to Azure DevOps.
Step 3
Move generated private key file to C:\Users\{username}\.ssh
.
On the same location create config
file with
Host ssh.dev.azure.com
IdentityFile ~/.ssh/privateKey
IdentitiesOnly yes
Step 4
Clone using SSH link.
Done!