Suppose I have the following git commits:
aaaaaa
bbbbbb
cccccc
(the latest)I would like to go back to bbbbbb
and continue the development from there. Essentially, I want to remove cccccc
for now and be able to retrieve it in the future (I know I'd still need the cccccc
). Should I revert cccccc
or rollback to bbbbbb
?
To undo changes associated with a specific commit, developers should use the git revert command. To undo every change that has happened since a given commit occurred, use git reset.
Just do:
git checkout -b dev_on_b bbbbbbb
which will leave the branch with cccccc alone and give you a new branch starting from bbbbbb. When you want to return to using ccccc you can do either of:
git merge branch_with_cccccc # bring cccccc into dev_on_b
or
git checkout branch_with_ccccc
Just do
git branch for_later
git reset --hard bbbbbb
Of course, don't do this if cccccc is already pushed. In that case, use revert.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With