gitvisual-studioazure-devopsazure-repos

How to push changes from or Azure Devops to another company?


I have a repository on our Azure DevOps and using Visual Studio 2022 I am able to create branches and do all other tasks before it is merged with the main branch.

I would like to push our main branch changes to a third party company who are also using Azure DevOps. They have provided me with access and I can see an empty repository.

I followed some instructions regarding Git commands where I have connected to their repository using a command such as

git remote add  some_name their_url

I then check to see if it's added

git remote -v

And its is listed. I have to set up some permissions on SSH but once that was completed I was able to gain access but received a repository error which the third party company are looking into.

Whilst I am waiting I decided to do a test against another domain to gain some idea of what to do. What I'm attempting to do is create a new branch and then push my changes to the third party repo.

I visited our DevOps and clicked my way to the point of creating a new Pull Request. On this screen I select main under source (on the left side) but i don't see the 'some_name' origin to push to their domain?

I clicked All and still didn't see the remote repo and not sure what I'm supposed to do from this point? All I would like to do is create a new branch and push that new branch to their repo (the third party repo)?

I can create a new branch off our main in Visual Studio but I don't see the options to push the newly created branch to their repo.

I have read a number of articles which have got me further but against the other DevOps I have access to I don't see any options so I don't know if I have missed something or not. I do have some access to the repo I am testing against but no access to the third party repo


Solution

  • All I would like to do is create a new branch and push that new branch to their repo (the third-party repo)?

    You can follow the following git command to push the branch to the destination repo in another organization. Assume your repo is named source and it has a branch called sourcebranch. The destination repo in another organization (the third-party repo) is called repodestination.

    git clone https://yourorgname@dev.azure.com/yourorgname/yourprojectname/_git/source
    cd source
    git remote add some_name https://theirorgname@dev.azure.com/theirorgname/theirprojectname/_git/repodestination
    git fetch origin sourebranch:sourebranch
    git push some_name sourebranch
    

    My test result: screenshot

    I visited our DevOps and clicked my way to the point of creating a new Pull Request. On this screen I select main under source (on the left side) but i don't see the 'some_name' origin to push to their domain?

    I clicked All and still didn't see the remote repo and not sure what I'm supposed to do from this point?

    I can create a new branch off our main in Visual Studio but I don't see the options to push the newly created branch to their repo.

    For these behaviors, in Azure DevOps, you can only create pull requests between branches within the same repository. The git remote add command works with your local Git configuration and does not affect the Azure DevOps interface. So, we can only select the branches in the repo to create a pull request instead of a branch from the remote.