Sobes.tech
Junior

How to combine multiple commits into one in Git?

sobes.tech AI

Answer from AI

git rebase -i HEAD~N
// N - number of recent commits to combine
// In the opened editor, change 'pick' to 'squash' or 's' for all commits except the first.
// After saving the file, Git will prompt you to enter a message for the combined commit.
git commit --amend
// Change the message of the last commit after combining