6

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?

Shayki Abramczyk
  • 36,824
  • 16
  • 89
  • 114
nuprap
  • 385
  • 5
  • 22

1 Answers1

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

Community
  • 1
  • 1
Shayki Abramczyk
  • 36,824
  • 16
  • 89
  • 114
  • I was considering this... but since the master branch is stale by several years, will this cause any issues when master is updated with the secondary branch? Based on what I read, I should consider using the -f flag if I chose this method... is that correct? – nuprap Mar 11 '19 at 13:48
  • 1
    clone the repo, copy him for backup, try what I suggested, succeed? good. not? try `-f` :) – Shayki Abramczyk Mar 11 '19 at 14:18
  • 2
    Step 3 should be "copy all files except the .git folder to a temp location Step 4 should be "Copy all the files from step 3 from the temp location and paste them over existing files. Changed behaviour in Windows makes this procedure do nothing if you do not use a physical temp location – Henrov Jun 18 '21 at 09:17
  • 1
    is this really the best option? only option? because you'd still have all that history of old commits, I would like to take a snapshot in time, before a series of bad commits, and promote that new master. – nagates Feb 24 '22 at 15:43