Home > Software design >  Reset temporary commits, modify, and redo the previous commits again
Reset temporary commits, modify, and redo the previous commits again

Time:12-01

When I work on a feature branch, I have to commit my temporary works from time to time, so that others can follow my newest changes, but I prefer to show the changes on this branch in my IDE.

The first step I can think of is:

git reset --soft HEAD~n

But how can I redo those commits so that I can create a new commit based on the original HEAD?

enter image description here

CodePudding user response:

Do you want to redo the commits that you have reset?

In that case, go like this

git reflog

and look for the message of the last commit before you did your reset.

Then reset to that hash.

git reset 147ad0

or something like that

Then if you chose the right commit, you will now only have the changes you made since your big reset as local changes. If you chose the wrong hash from your reflog, you can try a different one. You because reset doesn't change the state of your files, you can try resetting over and over again until you like what you see.

  •  Tags:  
  • git
  • Related