Git Config Cookbook/Auto setup remote on first push

Set upstream automatically for first push.

Section: Pull, Push, and Merge Policy

Auto setup remote on first push

bash
bash
git config --global push.autoSetupRemote true

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Pull, Push, and Merge Policy
Use simple push default
Push current branch to its upstream when names match.
OpenIn sheetbashsame section
Require fast-forward pulls
Fail pull if it would create a merge commit.
OpenIn sheetbashsame section
Rebase merges on pull
Rebase and preserve local merge structure.
OpenIn sheetbashsame section
Enable auto-stash on rebase
Temporarily stash dirty worktree during rebase.
OpenIn sheetbashsame section
Prune on fetch
Remove stale remote-tracking refs on fetch.
OpenIn sheetbashsame section
Set repo-specific user name
Override global identity in one repository.
OpenIn sheetbash1 tag match