github上有個功能叫fork,能夠將別人的工程複製到本身帳號下。python
這個功能很方便,但其有一個缺點是:當源項目更新後,你fork的分支並不會一塊兒更新,須要本身手動去更新。git
以gitHub用戶:lyt-Python(組織名或者用戶名),fork 項目scrapy(https://github.com/scrapy/scrapy.Git)爲例子:github
一、clone 本身帳號裏fork的分支scrapy
git clone https://github.com/lyt-python/scrapy.git
cd scrapy
二、增長遠程原始分支到本地(能夠用 git remote -v
命令查看遠程分支列表)fetch
git remote -v
origin https://github.com/lyt-python/scrapy.git (fetch)
origin https://github.com/lyt-python/scrapy.git (push)
若是沒有遠程原始分支則須要增長:spa
git remote add scrapy https://github.com/scrapy/scrapy.git
查看確認遠程分支列表:.net
git remote -v
origin https://github.com/lyt-python/scrapy.git (fetch)
origin https://github.com/lyt-python/scrapy.git (push)
scrapy https://github.com/scrapy/scrapy.git (fetch)
scrapy https://github.com/scrapy/scrapy.git (push)
三、fetch原始源分支的新版本到本地code
git fetch scrapy
會有以下信息:rem
- remote: Counting objects: 2147, done.
- remote: Compressing objects: 100% (11/11), done.
- remote: Total 2147 (delta 1280), reused 1280 (delta 1280), pack-reused 856
- Receiving objects: 100% (2147/2147), 490.60 KiB | 39.00 KiB/s, done.
- Resolving deltas: 100% (1585/1585), completed with 204 local objects.
- From https://github.com/scrapy/scrapy
- * [new branch] 0.12 -> scrapy/0.12
- * [new branch] 0.14 -> scrapy/0.14
- ...
- * [new tag] 1.2.0dev2 -> 1.2.0dev2
四、合併兩個版本的代碼get
git merge scrapy/master
會有以下信息:
- Updating a5db7f8..ebef6d7
- Fast-forward
- .bumpversion.cfg | 2 +-
- .travis.yml | 7 +-
- CODE_OF_CONDUCT.md | 50 ++++
- ...
- ...
- create mode 100644 scrapy/xlib/pydispatch.py
- create mode 100644 tests/test_pydispatch_deprecated.py
五、把最新的代碼提交到github本身(lyt-python)的帳號上
git push origin master
會有以下信息:
- Counting objects: 1802, done.
- Delta compression using up to 24 threads.
- Compressing objects: 100% (558/558), done.
- Writing objects: 100% (1802/1802), 280.30 KiB | 0 bytes/s, done.
- Total 1802 (delta 1395), reused 1644 (delta 1241)
- To https://github.com/lyt-python/scrapy.git
- a5db7f8..ebef6d7 master -> master