轉自: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的方法相同。