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.
CodePudding user response:
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.
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]
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:
git remote add azure https://azure.git
git push -u newbranch azure
CodePudding user response:
One way to achieve this by creating a new branch and making a pull request on Azure.
- In your GIT cmd, type
git checkout -b new-branch-name
- Then add all the changes you want to push, type
git add .
- and then
git commit -m "message"
- lastly push the changes by typing
git push origin new-branch-name
After pushing the changes, you may get prompt for entering git credentials, do that. after entering credentials, on your Azure git, you will see a button "Create Pull Request". I hope you can do the rest by yourself. For any help, please comment.