Fork A Repo

1,贡献代码给开源项目

有的时候你想贡献带代码给已经开源的项目,或者使用别人的项目作为初始开发点,这就叫做forking。这里使用Spoon-Knife作为教程。


step1: Fork “Spoon-Knife”到你的代码仓库中

在Spoon-Knife的GitHub页面上点击Fork按钮

Click "Fork"

step2: 克隆Fork出来的代码到本地

你已经成功Fork了Spoon-Knife项目,但只是存在GitHub上面,需要克隆到本地才能查看或者开发。

$git clone https://github.com/username/Spoon-Knife.git
# Clones your fork of the repository into the current directory in terminal

step3: 配置remotes

克隆成功后repo会有一个缺省的remote,叫做origin,指向你自己的GitHub上面的Fork,并不是指向最初始的开源项目,

所以为了更新源repo,需要增加一个另一个remote,叫做upstream

$cd Spoon-Knife
# Changes the active directory in the prompt to the newly cloned "Spoon-Knife" directory

$git remote add upstream https://github.com/octocat/Spoon-Knife.git
# Assigns the original repository to a remote called "upstream"

$git fetch upstream
# Pulls in changes not present in your local repository, without modifying your files

2,更多可以做的事

Push Commits

$git push origin master
# Pushes commits to your remote repository stored on GitHub
Pull in upstream changes

从初始项目上更新代码到本地repo

$git fetch upstream
# Fetches any new changes from the original repository
$git merge upstream/master
# Merges any changes fetched into your working files

Create branchs

创建新的分支


Pull Requests

如果你希望贡献代码给初始的开源项目,可以发送一个pull request给该项目的拥有者,查看向导


Unwatcher the main repo

fork过后如果不想从源repo上更新,点击Unwatcher退订


Delete the fork

当你想删除某个fork时,请查看向导

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值