Home > database >  Best way to PR Main branch after all commits were created in Main
Best way to PR Main branch after all commits were created in Main

Time:09-30

I have a main branch that was initialized. All work was done on this main branch with quite a few commits. I've created a branch now off of main that reflects all the code changes.

What is now the best practice to remove/revert everything from the main branch so that I can facilitate a PR back into Main?

Options I see as available:

  • Create a branch off of main and push branch; then delete all files from main; perform a revert on main; PR branch into main
  • Copy files locally from git repo; revert main branch; cut new branch and paste in local file changes and push; PR branch into main

Note: I'm using Azure DevOps and am looking to use their PR functionality.

Edit: An excellent comment below from @LasseV.Karlsen stated I should reach out to my organization, which is something that will be done. In asking this question though I'm looking for what the best practice is to follow in this situation.

CodePudding user response:

you can reset your main branch back to the very first commit:

git reset --hard <fist commit.>

if reset is not possible:

  1. delete everything on the main branch
  2. commit the change.
  3. merge the change to your feature branch.
  4. revert the merge commit : git revert HEAD
  •  Tags:  
  • git
  • Related