Progress:
TIER 1 · MODULE 21· Basics

git push

Append-only by default. Force-push only when you mean it.

🎯 What & why

Send commits and refs from your local repo to a remote. Append-only by default — the remote refuses non-fast-forward updates unless you force it.

🧠 Mental model

Push asks the remote to update its refs to point at your commits, sending whatever objects the remote doesn't already have. The remote runs receive-pack to validate (hooks, ACLs, ref-update rules) and then writes refs.

🛠️ Synopsis

git push [--all | --branches | --mirror | --tags] [--follow-tags] [--atomic]
         [-n | --dry-run] [--receive-pack=<git-receive-pack>]
         [--repo=<repository>] [-f | --force] [-d | --delete] [--prune]
         [-v | --verbose] [-u | --set-upstream] [-o <string> | --push-option=<string>]
         [--[no-]signed|--signed=(true|false|if-asked)]
         [--force-with-lease[=<refname>[:<expect>]]] [--force-if-includes]
         [--no-verify] [<repository> [<refspec>...]]

🎚️ Switches & options

FlagWhat it does
-u, --set-upstreamSet upstream tracking on first push.
--tagsAlso push tags.
--follow-tagsPush tags reachable from the pushed commits.
--force, -f⚠️ Force-push. ⚠️ Overwrites the remote ref. Don't use on shared branches.
--force-with-leaseSafer force-push: only if the remote tip is what you expect.
--force-if-includesBelt and suspenders for force-with-lease.
-d, --delete <ref>Delete a ref on the remote.
--dry-run, -nShow what would happen.

💡 Use cases

🧪 Examples

First push of a new branch with tracking.
$ git push -u origin feature/login
Push tags reachable from this commit.
$ git push --follow-tags
Safer force-push after rebasing.
$ git push --force-with-lease origin feature/login
Delete a remote branch.
$ git push origin -d feature/old

🎓 Recommendations

🪤 Common pitfalls

🔗 Related modules

📝 Quiz

Hit each option, then Check answers. Score is recorded; Next is always open.