Junior — Middle
How can multiple changes be combined into a single commit in a version control system?
sobes.tech AI
Answer from AI
To merge multiple changes (commits) into a single commit in the Git version control system, the git rebase operation with interactive mode is used.
Example:
- Run the command:
git rebase -i HEAD~N
where N is the number of the most recent commits you want to combine.
-
In the editor that opens, replace
pickwithsquash(ors) for the commits you want to merge with the previous one. -
Save and close the editor, then edit the message of the final commit.
This allows you to combine several commits into one, keeping the history cleaner and easier to read.