Reputation: 10907
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
?
Upvotes: 10
Views: 7281
Reputation: 70235
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
Upvotes: 9
Reputation: 301547
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.
Upvotes: 8
Reputation: 41848
The correct solution depends on whether this is a public git repository or not.
If you use this command, git revert HEAD^
then it will revert to (2), which may be the correct thing.
But, you will need to make certain that you revert back to (3) when you do a (4) and then merge in the changes when you commit again.
You may want to look at this, as it will discuss different options, based on different situations: http://book.git-scm.com/4_undoing_in_git_-_reset,_checkout_and_revert.html
Upvotes: 1