Question

Let say I have a patch series ready for submitting to some open source project. For instance, A, B, C, D, and E which correspond to individual commit. After commit C, I found several minor mistakes (e.g., coding style), I fixed several places where all commits (A to E) are somehow related. And, I commit the change to F. The question is:

Can I apply the changes in F to the separated commits (i.e., A to E), while maintaining the commits of A to E?

Was it helpful?

Solution

You can edit individual commits in a series by using interactive rebase (git rebase -i). However, note that if you have already published the commit series, rebasing can have significant consequences, since it rewrites history.

As long as you've kept the patch series private so far, however, it shouldn't be a problem to rebase it. You can use the "edit" action, which will cause the interactive rebase to stop before a given commit to allow you to modify it (after which you can continue with git rebase --continue).

For more details, see git help rebase.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top