Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to completely replace master with another branch in Azure DevOps

Using Azure DevOps, there is a repo with valid code being maintained in a secondary branch. However, the master branch is multiple years out of date.

I want to obliterate the contents of master and overwrite it with the contents of the secondary branch.

I understand that mishandling this can cause serious namespaces issues and I would like to avoid that.

What method would you recommend for completely replacing master with a secondary branch in Azure DevOps?

like image 376
nuprap Avatar asked Mar 06 '19 19:03

nuprap


People also ask

How do I change the main branch to master in Azure DevOps?

Under your project repo, select Branches. On the Branches page, select More options next to the new default branch you want, and choose Set as default branch. After you set the new default branch, you can delete the previous default if you want.

How do I overwrite a master in git?

Using the -f flag, your previous master is completely overwritten with develop , including its history.


1 Answers

  1. Clone the repo to your local machine.

    git clone {repo url}

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

    git checkout {secondary branch}

  3. Copy all the content - Ctrl+A, Ctrl+C.

  4. Move back to master branch.

    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 Azure DevOps.

    git push

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

like image 65
Shayki Abramczyk Avatar answered Oct 04 '22 20:10

Shayki Abramczyk