git push
Upload local commits to a remote repository
Practical example
git push origin main # push main branch git push -u origin feature-login # push and set upstream git push origin --delete old-branch # delete remote branch
Command overview & how it works
Sends committed changes from your local repository to a remote, making them available to collaborators. The basic syntax is git push <remote> <branch>, which pushes the specified branch to the matching branch on the remote. If the remote has commits you do not have locally, Git rejects the push — you must pull or fetch first. Use git push -u origin main to set the upstream tracking relationship, which lets you use just git push thereafter. Use git push --force (or -f) to overwrite the remote history — dangerous and should only be used on private or feature branches after rebasing. Use git push --dry-run to see what would be pushed without actually doing it. Use git push origin --delete <branch> to delete a remote branch. Never force-push to shared branches like main.
Master upstream tracking, SSH auth, and team workflows
Upstream sync strategies, merge vs rebase on pull, and semantic release tagging in the 97-page course — ₹499.
Practical tips
- Use git push -u origin main the first time so later pushes can simply be git push.
- If the remote rejects your push, pull or fetch first — the remote has commits you do not have locally.
- Never force-push to shared branches; if you must, prefer --force-with-lease, which refuses if the remote has moved.
Deep-dive guides & tutorials
In-depth walkthroughs and practical scenarios related to git push
- Guide
Git SSH Setup: Secure Authentication for Remote Repositories
Set up SSH keys for password-less, secure Git operations. Connect to GitHub, GitLab, and any Git server without typing credentials.
5 min readRead guide - Guide
Git Submodules: Managing Dependencies Across Repositories
Include one repository inside another with git submodules. A practical guide to adding, updating, and working with nested repos.
7 min readRead guide - Tutorial
Git Tagging: Versioning Your Project Milestones
Mark important commits with tags for releases, versions, and milestones. Learn lightweight vs annotated tags and how to share them.
4 min readRead guide
Related commands
More from Remote Repositories