So typically I'd just delete the remote branch and recreate it however:
- We have a variety of integrations Hooks etc. that will get messed up if I delete and recreate it.
- Our repository does not allow git push -f
- BranchA and BranchB are both based on and several commits ahead of Master
What is the best way to sync remote/BranchA with remote/BranchB
Only way forward I can see is Revert back to whatever similar SHA I can find between the two branches and then doing a merge forward to match BranchA to BranchB but I'd like to get this setup in an script I can execute on demand without having to do a bunch of research to find a similar baseline SHA. Any git magic that I'm missing that might help?
Update
git checkout BranchA
git reset --hard origin/BranchB
git push -f
Would be a way to accomplish this and rewrite history in the process. How do I do it without using git push -f and overwriting history since our repo doesn't allow it.
Update
git merge-base BranchA BranchB
returns the Sha and then
git checkout BranchA
git reset --hard [whateverSha]
git merge BranchB
git push
Does it but It needs to Grep out the SHA first and would still need to push -f.