Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
475 views
in Technique[技术] by (71.8m points)

git - Azure DevOps remote branches are not visible in one repository

The list of actions I do and the result:

  1. Locally I have a master branch and I have it on a remote.

  2. I create a dev/test branch locally

  3. I push it to the remote

  4. On the Azure DevOps website I can see that branch appeared in Branches in the "Mine" tab.

  5. 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
question from:https://stackoverflow.com/questions/65940525/azure-devops-remote-branches-are-not-visible-in-one-repository

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 "[email protected]".

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

enter image description here

Step 4
Clone using SSH link.

Done!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...