github更新本身Fork的代码

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

  1. remote: Counting objects: 2147, done.  
  2. remote: Compressing objects: 100% (11/11), done.  
  3. remote: Total 2147 (delta 1280), reused 1280 (delta 1280), pack-reused 856  
  4. Receiving objects: 100% (2147/2147), 490.60 KiB | 39.00 KiB/s, done.  
  5. Resolving deltas: 100% (1585/1585), completed with 204 local objects.  
  6. From https://github.com/scrapy/scrapy  
  7.  * [new branch]      0.12       -> scrapy/0.12  
  8.  * [new branch]      0.14       -> scrapy/0.14  
  9. ...
  10.  * [new tag]         1.2.0dev2  -> 1.2.0dev2  

    四、合并两个版本的代码get

git merge scrapy/master  

会有以下信息:

  1. Updating a5db7f8..ebef6d7  
  2. Fast-forward  
  3.  .bumpversion.cfg                                   |   2 +-  
  4.  .travis.yml                                        |   7 +-  
  5.  CODE_OF_CONDUCT.md                                 |  50 ++++  
  6. ...
  7. ...
  8.  create mode 100644 scrapy/xlib/pydispatch.py  
  9.  create mode 100644 tests/test_pydispatch_deprecated.py  

五、把最新的代码提交到github本身(lyt-python)的帐号上

git push origin master  

会有以下信息:

 

  1. Counting objects: 1802, done.  
  2. Delta compression using up to 24 threads.  
  3. Compressing objects: 100% (558/558), done.  
  4. Writing objects: 100% (1802/1802), 280.30 KiB | 0 bytes/s, done.  
  5. Total 1802 (delta 1395), reused 1644 (delta 1241)  
  6. To https://github.com/lyt-python/scrapy.git  
  7.    a5db7f8..ebef6d7  master -> master  
相关文章
相关标签/搜索