Search code examples
gitcommitrevision

How to commit in a specific git revision?


I would like to commit my changes for a bug fix in an older revision, in which I committed other changes for the same bug, so that the history is organized. I mean like an amend commit, but this one commits in the last revision, not in an older one. How could it be possible to do that?


Solution

  • Commit the fix, then use git rebase -i OLDER. You can then reorganize the commits in the editor to move your new fix up with all of the old ones.

    This will rewrite all of the history in that range, so if you have pushed these changes anywhere you will be causing trouble for everyone else. This is the kind of thing you do only in your own topic branch in your private repository before submitting changes to an upstream or merging the project branch back to the trunk.