🌱 BasicsCommonly used
How to push changes to a remote repository
Upload your local commits to a remote repository.
Push current branch
git push origin mainPushes the main branch to the origin remote.
When to use: Standard push to main/master branch.
Push and set upstream
git push -u origin feature-branchPushes the branch and sets the upstream so future "git push" works without arguments.
When to use: First push of a new local branch. After this, just use git push.
Force push (use with caution)
git push --force-with-lease origin branchOverwrites remote history but fails if someone else has pushed. Safer than --force.
Rewrites remote history. Only use on branches you own. Never on main/master.
Push all branches
git push --all originPushes all local branches to the remote.
Push tags
git push origin --tagsPushes all local tags to the remote.