1. 程式人生 > >Github上fork專案後與源專案同步

Github上fork專案後與源專案同步

先上一個流程圖

這裡寫圖片描述

  1. 首先是fork一個專案到自己的Github上
  2. 把自己Github上的程式碼clone到本地
git clone https://github.com/wxxiong6/phpstorm-stubs.git

檢視遠端版本

git remote -v

結果

origin  https://github.com/wxxiong6/phpstorm-stubs.git (fetch)
origin  https://github.com/wxxiong6/phpstorm-stubs.git (push)

只能看到自己Github

  1. 新增源專案遠端master git remote add phpstorm
    這個phpstorm 是自己取的名字
git remote add phpstorm https://github.com/JetBrains/phpstorm-stubs.git

再次檢視

git remote -v

結果

origin  https://github.com/wxxiong6/phpstorm-stubs.git (fetch)
origin  https://github.com/wxxiong6/phpstorm-stubs.git (push)
phpstorm    https://github.com/JetBrains/phpstorm-stubs.git (fetch)
phpstorm    https://github.com
/JetBrains/phpstorm-stubs.git (push)
  1. 獲取源專案遠端的程式碼
git fetch phpstorm

結果

remote: Counting objects: 595, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 595 (delta 241), reused 244 (delta 241), pack-reused 350
Receiving objects: 100% (595/595), 206.25 KiB | 147.00 KiB/s, done.
Resolving deltas: 100
% (301/301), completed with 65 local objects. From https://github.com/JetBrains/phpstorm-stubs * [new branch] master -> phpstorm/master * [new tag] 2018.1.2 -> 2018.1.2

檢視分支

git branch -av

結果

* master                            8005fdd Update yaf_namespace.php
  remotes/origin/HEAD               -> origin/master
  remotes/origin/master             8005fdd Update yaf_namespace.php
  remotes/origin/pr/117             306cc3c introduced first module - standard
  remotes/origin/revert-333-patch-2 0d74e4b Revert "Fix date() $timestamp default value"
  remotes/phpstorm/master           d7f7ad6 Fixed rdkafka extension folder name to be compatible with "Sync Extensions with Interpreter" action
  1. 合併程式碼

master

git merge phpstorm/master

結果

Updating 8005fdd..d7f7ad6
Fast-forward
 .travis.yml                                                |   19 +
 CONTRIBUTING.md                                            |    4 +
 Core/Core.php                                              |   29 +-
 Core/Core_c.php                                            |   37 +-
  1. push到自己遠端master
git push -u origin master

就算完成了