How to modify master in Git (in this situation)
I am using git (from visual studio but I don't think that is that relevant) and I have come to have the following situation
As you can see there are four branches (BX) and several other commits in between. Also the master branch (M) -which is in red.
Well, due to my inexperience, I have gotten into the situation that the stable version of my program is in B3. I made some experimentation in B4 but I think that I will discard it. -I know how to do it, no problem there.
However- the master branch is in a completely different direction. The two commits toward it have things that I don't care about and that I absolutely don't want in my already working program.
So my question is - since "master" is supposed to be the stable release- how do I make master point to where B3 is???
This must be a really basic question but I trust in the advice of experienced people
One potential solution (if these are all local feature branches you have created) is to do the following:
git branch -d B4
git checkout master
git reset --hard <SHA of B2's commit you want>
git checkout B3
git rebase B3 master
This will delete branch B4
, remove the commits from master
that you do not want, and then replay all the commits from the B3
branch that you want onto the head of master
. Keep in mind you may need to resolve some conflicts during the rebase. When you finish resolving them, run git rebase --continue
.
The simplest thing to do is
git branch -f master B3
git checkout master
This abandons the old master and moves it to B3.
链接地址: http://www.djcxy.com/p/3968.html上一篇: f来源大师'任何方式来恢复?