转自:http://blog.sina.com.cn/s/blog_4b55f6860100zzj3.htmlhtml
有时候你可能想给别人的项目出把力,或者想以别人的项目做为本身项目的起点,在Github里面称做forking。这里使用的是Spoon-Knife项目做为示例。git
1.Fork “Spoon-Knife” 这个repogithub
点击Forkfetch
2.设置本地repourl
如今你的GitHub中已经有了Spoon-Knife这个repo,接下来要clone克隆到本地电脑上。htm
(1)使用下面的命令来克隆:blog
$ git clone git@github.com:username/Spoon-Knife.gitrem
(2)配置远程get
$ cd Spoon-Kniferequests
做用:Changes the active directory in the prompt to the newly cloned "Spoon-Knife" directory
$ git remote add upstream git://github.com/octocat/Spoon-Knife.git
做用:Assigns the original repo to a remote called "upstream"
$ git fetch upstream
3.更多能够作的事情
(1)push commit
若是要对已forked的repo执行一些commit,并push到forked项目中,能够和常规repo同样来操做:
$ git push origin master
(2)pull in upstream变化
若是你所forked的项目已经更新过,能够使用代码来将更新添加到fork中:
$ git fetch upstream
做用:Fetches any new changes from the original repo
$ git merge upstream/master
(3)使用分支来工做
(4)pull requests
(5)中止关注main repo
(6)删除fork
和删除通常repo的方法相同。