1

Given the following notional Git history:

A--B--C    (origin/master)  *dead branch*
   \--D--E (working)        *live branch, preferred master*

Is there any way to move origin/master to the working live branch, and keep on rolling? I'm very aware of "Why'd you let origin/master go dead? Don't do that", and I will carefully heed that advice in the future. But that's my current reality, and I'm asking for extraction advice.

Update 2019-08-22: Here's another very useful post if what you actually want to do is delete the remote master branch. I found @SlightlyCuban's answer to be most helpful here in non-GitHub situations where you have shell access to your remotes.

Also, deleting the local branch that's tracking the remote branch is explained well in this answer.

dave_k_smith
  • 655
  • 1
  • 7
  • 22
  • 1
    What do you mean by "recover origin/master over to the working live branch"? – Minar Mahmud Jan 02 '19 at 23:25
  • @MinarMahmud good point, "recover" was not a good word choice. I changed it to "move", and added more explanation for my situation. Hopefully it's clearer now. – dave_k_smith Jan 03 '19 at 02:36

2 Answers2

2

If you don't want to force push (because other developers would need to reset their branch), you can replace master by your new branch content:

git checkout master
git pull
git checkout working
git merge -s ours master
git checkout master
git merge working

Then you can do a simple push

git push

And other developers, when doing a git pull, will get a master with a copy of working in it.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

You can execute git push -f origin working:master if you want to override remote branch. And, as you've said, this is not a good idea as anyone who works on that branch has to do god knows what, a rebase might not help im not sure