git pull --rebase --autostash

Fetch and rebase remote updates onto your branch while auto-stashing local changes

This command fetches remote changes, rebases your local commits on top while automatically stashing and reapplying any uncommitted local modifications.

By default git pull merges remote updates into your branch, but with --rebase it replays your local commits on top of the newly fetched commits. Adding --autostash ensures that any uncommitted work is temporarily stashed before the rebase and reapplied afterward so you don’t lose or manually manage your changes.

You can shorten --rebase to -r and omit --autostash if you prefer to handle stashes yourself with git stash. For a more granular rebase you might use --rebase=interactive, or you can split this into two steps—git fetch followed by git rebase origin/<branch>—to get finer control. Alternatively, using git pull --rebase=merges preserves merge commits instead of flattening them.

Related commands

Welcome to GitExamples!

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