Sobes.tech
Junior

What is the difference between the 'amend' and 'squash' commands in Git?

sobes.tech AI

Answer from AI

git commit --amend modifies the last commit by adding the changes made or correcting the commit message. Essentially, it replaces the last commit with a new version, creating a new SHA hash.

git rebase --interactive with the squash option allows you to combine multiple consecutive commits into one. You select the commits to merge, and Git creates a new commit that consolidates all the selected changes. The commit history is rewritten, new SHA hashes are generated for the merged commits and all subsequent ones.