推送
一句话解释
Pushing uploads 你的 局部 提交 到 remote 仓库 所以 others 能 see and 拉取 它们.
用大白话说
git push sends your local commits to a remote repository. After you commit changes locally, they exist only on your machine. Pushing publishes them to the server (e.g. GitHub) so collaborators can see and pull them.
The typical command is git 推送原点主要 — push the local 主要 branch to the 原点 remote. If the remote has commits you do not have locally, the push is rejected. You must pull first to integrate the remote changes, then push again.
Pushing is a one-way upload of your history. It does not merge or modify your local files — it only transfers commits you already have. The first push of a new branch uses git 推送 -u 原点 <分支> to set up tracking, so future git 推送 commands work without arguments.
示例
# Push local main to origin
git push origin main
# First push of a new branch (sets up tracking)
git push -u origin feature/login
# After tracking is set up, just:
git pushgit 推送 uploads 局部 提交 到 remote. -u 设置 上 tracking for 新 分支.
工作原理
- You commit changes locally.
git 推送原点 <分支>uploads your commits to the remote.- If the remote has commits you lack, the push is rejected — pull first.
- On success, the remote branch now matches your local branch.
相关术语
相关资源
相关课程
- GitHub 基础
Pushing 到 GitHub
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。