git push -n

Show what would be pushed to the remote without actually pushing anything.

This command is useful when you want to double-check what commits and refs would be sent to a remote before actually modifying it, acting as a dry run for a push operation.

This command uses the -n flag (same as --dry-run) to simulate a push: Git connects to the remote, figures out which branches/tags would be updated and which objects would be sent, and then prints that information without transferring any data or changing the remote repository. The base push part says “send local commits to the configured remote,” while the -n/--dry-run modifier tells Git to stop after planning the operation, so no refs are updated and no changes are made on the server.

You can combine this with other options to preview specific pushes, for example git push -n origin main to simulate pushing just the main branch to origin, or git push -n --force to see what a force-push would update without doing it; a related command is git push --force-with-lease, which can also be paired with -n to preview a safer force-push. Other complementary operations include git status to see local changes before committing, and git diff origin/main..main to inspect what would eventually be sent before using a dry-run push.

Manual page
git push
Related commands

Welcome to GitExamples!

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