[SOLVED] How to clone single branch from one repo to empty new repo?


This Content is from Stack Overflow. Question asked by Darshika Srivastava

How to clone one single branch from repository ‘A’ to other new repo ‘B’ in azure?

I’ve cloned the repo ‘B’ in VS Code, it is empty, so there is one branch only which is main then I opened repo ‘A’, branch I want to clone then copied HTTPS link.

In VS Code terminal I used ‘git clone –single-branch –branch ‘name’ ‘link’.
I am able to run the project locally, but I am not able to push it back to azure.


I’m not sure is there any shortcut to do that, but you always can push specific branch to another remote that you’ve just cloned.

  1. Firstly you have to add the azure remote that you mention by this command
    git remote add [name of the remote] [git address of the remote]

  2. Push specific branch to that remote by this command
    git push -u [name of the remote] [name of the branch you wanna push]

for example:

  1. git remote add azure https://azure.git
  2. git push -u newbranch azure

This Question was asked in StackOverflow by Darshika Srivastava and Answered by wlminus It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?