0

I am in a kind of limbo. I had one branch named Branch_A along with the master branch which were exactly the same. I was supposed to make new branch Branch_B and commit/push every thing on that branch. Unfortunately, I committed every thing on master branch. I have one local branch Branch_B where are all file were committed. I was supposed to commit all those on Branch_B remotely but I did it in master branch. Now I want to do the following:

  1. Make remote Branch_A the master branch and keep remote Branch_A as it is
  2. Make remote branch B and push the commits from local branch B there.

What is the best way to achieve this?

Gaʀʀʏ
  • 4,372
  • 3
  • 39
  • 59
sumit
  • 15,003
  • 12
  • 69
  • 110

3 Answers3

0

I think the best way to do this is like this

  1. If you have not staged files commit them to your current development branch (branch b)
  2. Merge current development branch with current master branch (branch b ** to **branch a)
  3. Then merge branch a with master

This way you will have your master branch fully up to date with your latest commits and then you can do your development to one of the other branches

Additional help

dstrants
  • 7,423
  • 2
  • 19
  • 27
0

It looks like you have pushed Branch_B to master. What you have to do is to force push your master. Use

git checkout master 
git push -f origin master
git checkout Branch_B 
git push origin Branch_B
ephemerr
  • 1,833
  • 19
  • 22
0

Apparently your local Branch_B points to the remote master -you can check this with:

git branch -vv

If this is the case then:

1.Make your local Branch_B track the remote one with the same name and push your changes there

git checkout Branch_B
git branch --unset-upstream
git branch --set-upstream-to=origin/Branch_B
git push

2.Force push your local master branch to the remote master branch so that the changes that you accidentally pushed there disappear

git checkout master 
git push -f
Christos Batzilis
  • 352
  • 1
  • 3
  • 12