Fork
一句话解释
Fork 是服务器-边复制的 仓库 under 你的 own account, 链接到 原始 for 拉取请求.
用大白话说
A fork is a complete copy of a repository made on the server (GitHub, GitLab). It lives under your account and maintains a link to the original repository (called "upstream"). Forking is the standard way to contribute to a project you do not have write access to.
The workflow: fork the original repo on GitHub, clone your fork locally, create a feature branch, make changes, push to your fork, then open a pull request from your fork to the original (upstream) repository.
Forks are different from clones: a fork is server-side and preserves the upstream link; a clone is a local copy. You typically clone your fork (not the original) so you can push changes. To stay in sync with the original, you add it as a remote called upstream and fetch from it periodically.
示例
# After forking on GitHub, clone YOUR fork
git clone https://github.com/you/project.git
cd project
# Add the original as 'upstream' to stay in sync
git remote add upstream https://github.com/original/project.git
git fetch upstreamFork on GitHub, 克隆你的 Fork, 添加 upstream remote for syncing.
常见混淆
容易混淆的对象: 克隆
关键区别: Fork 是服务器-边复制 under 你的 account 使用 upstream 链接; 克隆是 局部复制 on 你的 machine. 你 Fork 到 contribute, 克隆到 工作 locally.
容易混淆的对象: 分支
关键区别: Fork 复制整个仓库到 新 account; 分支是 行的 development 在内相同仓库. Fork 是 for cross-account contribution; 分支是 for 内部 development.
相关术语
相关资源
相关课程
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。