Reputation: 614
In master branch I have the following commits: master: a,b,c,d,e,f However I made a mistake which I have to checkout from commit c and made a new branch from it
git checkout c
git checkout -b master2
master2 has the latest commits and now i want to put them to master branch without having to deal with possible conflicts. I want master branch to have all the latest commits in master2 without d,e and f commits
Upvotes: 1
Views: 52
Reputation: 1600
You can do what are asking for in one step.
git checkout -B master c
git checkout <commit>
will update the working tree to the commit specified
-b <branch>
flag will create a new branch. But we are using -B <branch>
(notice the uppercase B
) which will point an existing branch to the commit specified.
Upvotes: 0
Reputation: 311723
The easiest approach would just to reset the master branch:
$ git reset c --hard # from the master branch itself.
Upvotes: 1