Practical Git via GitExtensions
  • Git - a Distributed System
  • Bare Minimal Configurations
  • Creating a New Branch
  • Making a Commit
    • Adding only a portion of a file
    • Commit Message
    • Cherry-pick
    • Revert
  • Rewriting History
    • Rewording the Last Commit
    • Rewording Commit Message in Middle
    • Editing the Last Commit
    • Squashing Last Few Commits
    • Squashing Commits in Middle
    • Spliting Commit into Multiple
    • Removing a Commit
    • Pushing after Rewriting History
  • Lost and Found
  • Comparing Commits or Branches
  • Checking out a Branch into Another Folder
  • Blaming History
    • Blame
    • Bisect
  • Disabling Auto Tracking Branch
  • Line Ending
  • Ignore Unwanted Files
Powered by GitBook
On this page

Was this helpful?

  1. Rewriting History

Squashing Last Few Commits

PreviousEditing the Last CommitNextSquashing Commits in Middle

Last updated 6 years ago

Was this helpful?

If just want to squash last few commits we can do a Mixed or Soft reset to their parent commit and recommit the changes.

Note: with Mixed reset, we have to stage the files again, whereas Soft will keep the files in staging area.

For example, in below image, we want to squash the last two commits WIP: Continue Fix blah blah and WIP: Fix blahblah. We can right click their parent commit my awesome changes, select the Reset current branch to here, then select the Mixed:xxx option.

Commmand line:

git reset HEAD~2
git add <the files> # or use git add -a to add all files to staging area
git commit