git pull --squash

Fetches and merges remote updates into your current branch as a single squashed commit.

This command is useful for integrating remote changes in one commit to keep your project history concise by collapsing all upstream commits into a single new commit on your branch.

When executed, this command first fetches updates from the remote repository and then prepares a merge that combines all fetched commits into your working tree without creating individual merge commits; it stages the combined changes so that you can edit the resulting commit message and run git commit to finalize the single squashed commit.

You can specify a remote and branch explicitly, for example git pull --squash origin <branch>, or rely on defaults set in your config; to achieve a similar effect locally you can use git merge --squash, and for more flexible history rewriting you can use git rebase -i to interactively squash commits.

Related commands

Welcome to GitExamples!

Sign in to enable bookmarking, reminders, progress-tracking and more...