github上有許多優秀的代碼,我們可以將其中的某一個項目的repository fork到自己的github賬戶,clone到本地進行閱讀,修改,還可已經自己的修改提交給原作者
本文介紹在以上過程中會用到的git相關指令
1. fork repository:以onlyliuxin/coding2017 這個repository爲例,進入到這個repository主頁面,點擊右上角fork按鈕。
fork完成後可以在自己的github賬號中看到一個repository,名稱是YOUR-USERNAME/coding2017
2. 將代碼clone到本地
$ git clone https://github.com/YOUR-USERNAME/coding2017.git
3. 將本地倉庫與原始倉庫同步
$ git remote add upstream https://github.com/onlyliuxin/coding2017.git
4. 從原始倉庫中抓取更新
$ git pull upstream master
5. 完成修改後,提交到自己的github遠程倉庫
git add .
git commit -m "......"
git push -u origin master
6. 向原始倉庫提交你的修改: