I am working on a local branch VISS. Then I decided to check out a previous commit:
git checkout 98ea3c8042c39e
I made some important changes to the code. and then I committed again.
Now I need to go back to my branch VISS keeping these changes.
What should I do if I want to:
-
Go back to my
VISSbranch discarding what was done before checking out to a previous commit (98ea3c8042c39e). -
Go back to my
VISSbranch merging the new changes with what I had done on the top of theVISS.
Go back to your branch and discard everything :
Your new commit atop
98ea3cwill be left floating in the middle of nowhere, and will eventually be garbage collected by git.Conversely, if you are willing to make
98ea3cthe top ofVISSand discard whatVISSis currently pointing to, do the following:Go back to
VISSand merge your new changes on the top of it:You’ll now have
VISSwith the change as the latest commit, and no merge commit.