Edit a few previous commits
Working in feature branch I put wrong issue number to commit message. In fact, I did it not with last commit, but with a two or three in a row.
If this is just a last commit you could easily use git commit --amend.
Finally I found solution on stackoverflow. I’ll quote it here:
If the commit you want to fix isn’t the most recent one:
git rebase --interactive $parent_of_flawed_commitIf you want to fix several flawed commits, pass the parent of the oldest one of them.
An editor will come up, with a list of all commits since the one you gave.
Change
picktoreword(or on old versions of Git, toedit) in front of any commits you want to fix. Once you save, git will replay the listed commits.Git will drop back you into your editor for every commit you said you want to reword, and into the shell for every commit you wanted to edit. If you’re in the shell:
Change the commit in any way you like.
git commit --amend git rebase --continueMost of this sequence will be explained to you by the output of the various commands as you go. It’s very easy, you don’t need to memorize it – just remember that git rebase —interactive lets you correct commits no matter how long ago they were.