git push
The command that uploads your commits to a remote and moves the remote's branch to match.
In more detail
The remote accepts the push only if it fast-forwards its branch; if someone else pushed first, or you rewrote history, it is rejected. git push -u origin branch also sets the upstream so later pushes need no arguments. Tags are pushed only when you name them, as in git push origin v1.0.
Example
git push origin mainRelated terms
- push event — The workflow event that fires when commits or tags are pushed to the repository.
- commit — A saved snapshot of the whole project in Git, together with its author, committer, time, message and a pointer to the commit before it.
- remote — A short name saved in a repository's config that stands for another repository's location, a URL or a path, so you can fetch from and push to it.
- upstream branch — The remote branch your local branch is linked to, which git push, git pull and git status use when you do not name one.
- force push — A push that makes the remote branch match yours even when that throws away commits the remote has.
- fast-forward — A merge where the current branch has nothing new, so Git simply moves it forward to the other branch's commit without creating a merge commit.
Taught in
- What Is a Pipeline? — Continuous Integration & Continuous Delivery Pipelines
- DORA Metrics: Measuring Your Pipeline — Continuous Integration & Continuous Delivery Pipelines
- Ignoring Files, And The Tracked File Trap — Advanced Git Internals & Distributed Workflows
- Undoing: restore, reset, revert And stash — Advanced Git Internals & Distributed Workflows
- What A Remote Actually Is — Advanced Git Internals & Distributed Workflows
- Clone, Forks, Push, And The Upstream Branch — Advanced Git Internals & Distributed Workflows
- Fetch Is Not Pull — Advanced Git Internals & Distributed Workflows
- The Pull Request, And Branch Naming — Advanced Git Internals & Distributed Workflows
- Reviewing Code Well — Advanced Git Internals & Distributed Workflows
- Amend, And The One Hard Rule — Advanced Git Internals & Distributed Workflows
- Interactive Rebase: Squash, Reorder, Reword — Advanced Git Internals & Distributed Workflows
- Tags And Releases — Advanced Git Internals & Distributed Workflows