I have git project like this below
% git --log
commit 39b6b1d894d0788fdfc09947e1a5f88bf962b142 (HEAD -> master, origin/master, origin/HEAD)
Author: whitebear man <[email protected]>
Date: Wed Nov 9 15:29:13 2022 0900
all
commit 2656df9fb80b5085b4e7a50032712b13e3c407c9
Author: whitebear man <[email protected]>
Date: Thu Oct 13 13:48:36 2022 0900
all
commit d72472d00c649fdc04805d10c856d729e114a014
Author: whitebear man <[email protected]>
Date: Wed Oct 12 18:23:28 2022 0900
all
commit 0878cd86de3a939e8c99e33676abcfe1cfd14daa
Author: whitebear man <[email protected]>
Date: Tue Oct 11 11:38:58 2022 0900
all
commit 21c78ba8cfb811e1ad7dfb035ef5236e619f5d53
Author: whitebear man <[email protected]>
Date: Mon Oct 10 15:55:48 2022 0900
all
commit 9568b4b53fd14febc1ed100efcc6d412d0668471
Author: whitebear man <[email protected]>
Date: Mon Oct 10 15:37:27 2022 0900
all
Now I want to roll back commit 21c78ba8cfb811e1ad7dfb035ef5236e619f5d53
and make new branch.
However I want to keep the latest commit 39b6b1d894d0788fdfc09947e1a5f88bf962b142
as master.
I should rollback and make new branch?
or make new branch and rollback??
CodePudding user response:
You could just create a new branch from the 21c78ba8
commit:
git branch new_branch 21c78ba8
CodePudding user response:
@Tim's answer is a good point if you don't really want to rollback. If, however, you really want/need to revert what was done in 39b6b1d894d0788fdfc09947e1a5f88bf962b142, this is the simplest way to do it:
git revert 39b6b1d894