Let say that I want to change HEAD~2 by my current last commit "HEAD" without the change made by HEAD~. Moreover, I'd like to edit the message from HEAD~2 and not overwrite it (just few changes should be done on the message).
I found that way :
this is my current git log :
Then I did this following command :
git reset --mixed Head~3
git add new_file.cpp
git commit -m "Erased previous new_file.cpp by current new_file"
git add other_file.cpp
git commit -m "Added other_file.cpp"
So now I get this :
As you can see, I have rewrite all my commit to make it clean. And as I am quite newbie on reset... it can be a bit dirty.
Could it be possible to get this cleaner just by "editting" the commits ? For instance I'd like to edit the previous message from the first commit and keep the message of the second intact.
Moreover, the way I did the modification let me think the previous commit are still present and must pollute the repository : will they be erased or stay there foreever ?
P.S : the GitHub repository (the reflog is quite horrible as I made some command mistake before finding the right command)