0

I have my main branch a bit messed up, nothing there matters anymore I want to bring everything as it is from a branch called dev into main

Since I want main to be now an exact copy of dev branch, I tried deleting everything on main branch and doing a normal merge, but to my surprise the previous history of previous files made a lot of conflicts and also made some files to simply not even merge at all and are not present after the merge, so this option did not work.

I also tried checkout to main branch, do a hard reset on dev branch and force push as suggested on some other place, also did not work, this operation just created another head on dev branch, weird.

Maybe I should find a way to completely clean out main branch and make it forget/ignore past history and just "accept" whatever is merged into it. If that works, how could I do that.

If there is another option, please let me know (I was having high hopes that force push dev branch into main would work, but I could not make that work either)

Thanks

  • 1
    *this operation just created another head on dev branch, weird* -> Can you expand on this? Reset seemed to be the correct course of action. (Also, there's no concept of "completely" forget as opposed to "shallow" forget, as if branches had undergound hidden metadata or something. A branch is a simple variable containing a commit hash.) – Romain Valeri Nov 23 '22 at 13:18
  • When I did the hard reset option, I saw no change whatsoever on main branch, thats the important part, so I'd say the hard reset of dev into main did not affect main at all, I would love for it to have worked – Gabriel Oliveira Nov 23 '22 at 13:28
  • 1
    *I saw no change whatsoever on main branch* -> Do you mean "no changes" by looking at actual files? or all clean in `git status` output? If you `git reset --hard dev` from your `main` branch, then yes they should be identical. – Romain Valeri Nov 23 '22 at 13:51

0 Answers0