git push
`git push` uploads your local commits to a remote repository, such as GitHub, making them available to others. You typically push to a specific branch on a specific remote.
The first time you push a new local branch, you use `-u` (or `--set-upstream`) to link it to a remote branch, so future pushes can just use `git push` without extra arguments.
git push origin <branch>
git push -u origin <branch>Pushing commits
Run `git push origin main` to upload commits on your local main branch to the origin remote's main branch.
Setting the upstream branch
Use `git push -u origin branch-name` the first time you push a new branch, which links it so future pushes and pulls just work with plain `git push`/`git pull`.
git push -u origin feature-loginBranch 'feature-login' set up to track remote branch 'feature-login' from 'origin'.Pushes a new branch to GitHub and links it for future push/pull commands.
git pushTo github.com:user/repo.git
a3f5c9e..9c2e1aa main -> mainPushes new commits on the tracked branch without needing to specify remote or branch name again.
Key points
- git push uploads local commits to a remote repository.
- -u sets up tracking so future pushes need no extra arguments.
- You push to a specific remote and branch, like origin main.
- Push can be rejected if the remote has commits you don't have locally.
