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