Issue
When making many changes to a file, I want the changes to be neatly divided into easily-comprehensible commits for my colleagues to review. For example, commit 1 might be to factor out repeated code into a separate method, then after I make commits 2 and 3 (but before I push) I see another place where the new method can be incorporated, and I'd like to put this change in commit 1. Is this possible? If necessary I could then manually update commits 2 and 3 to incorporate this change.
Solution
You can use Interactive Rebase for that as follows:
- Make a new commit with the changes for commit 1
- In the History view right-click the commit before commit 1 and choose Interactive Rebase
- In the Interactive Rebase view move the new commit to commit 1 and squash both commits
Answered By - howlger
Answer Checked By - David Marino (JavaFixing Volunteer)