1
votes

I'm looking for steps to push feature branch on repository A to master branch of repository B using command line steps on azure DevOps build pipeline. Thanks

2
How well this will work depends on how similar the two repositories are.Ripp_
Did this two repository in the same team project or same collection in Azure DevOps Sever?PatrickLu-MSFT
@PatrickLu-MSFT, its in the same team project of same collection of azure devops server.Uday

2 Answers

1
votes

The simplest way is through Pull Request. But it depends if there exist Fork relationship between current(repoA) and target(repoB) repos.

In other word, one repos must be forked from another repos if you want to create pull request across repos.

enter image description here

At this time, you will has option to choose another repos/project while you creating the Pull request.

enter image description here

More details please take a look at the answer in this question: Azure DevOps : Pull Request across the Repositories?

Otherwise you need to use multiple git commands to achieve this:

  1. Separately Clone the repoA and repoB to your local machine.

    git clone {repo urla} git clone {repo urlb}

  2. Go to the local repo and move to the feature branch.

    git checkout {feature branch}

  3. Copy all the content - Ctrl+A, Ctrl+C.
  4. Move back to master branch in repoB.

    git checkout master

  5. Paste the files (and replace existing files) Ctrl+V.
  6. Commit the changes.

    git add .

    git commit -m "update master"

  7. Push the changes to remote repoB inAzure DevOps .

    git push

Now the master branch updated with the content of the feature branch.


Besides, you could also try to use this 3-rd party extension --Git Merge in marketplace.

Test merges for conflicts between git branches OR actual merge commit and push of two git branches

0
votes

apparently, in the comments. everything command is coming as single line. So, here it is again.

here, is the git commands which fixed the ask for me.

to clone single feature branch from Repo A

git clone -b feature/feature-test --single-branch

creating a new branch with name as master.

git checkout -b master

adding remote url of Repo B

git remote add origin-feature

pushing to Repo B

git push origin-feature master