1, 同步到原项目
- #fork项目后与原项目进行同步
- #首先clone自己
leodemac-mini:git_test leo$ git clone https://github.com/bamboolsu/openwebrtc-examples
#添加远程仓库 再将别人的版本库git remote add
leodemac-mini:openwebrtc-examples leo$ git remote add bamboolsu https://github.com/EricssonResearch/openwebrtc-examples
leodemac-mini:openwebrtc-examples leo$ git remote -v
bamboolsu https://github.com/EricssonResearch/openwebrtc-examples (fetch)
bamboolsu https://github.com/EricssonResearch/openwebrtc-examples (push)
origin https://github.com/bamboolsu/openwebrtc-examples (fetch)
origin https://github.com/bamboolsu/openwebrtc-examples (push)
leodemac-mini:openwebrtc-examples leo$ git fetch bamboolsu
leodemac-mini:openwebrtc-examples leo$ git merge bamboolsu/master
git remote add epix37 https://github.com/Epix37/Hearthstone-Deck-Tracker.git-
#如果有冲突则需要手动解决冲突,
leodemac-mini:openwebrtc-examples leo$ git merge bamboolsu/master
leodemac-mini:openwebrtc-examples leo$ git commit -m "merge from bamboolsu"
leodemac-mini:openwebrtc-examples leo$ git push -u origin master
- #查看本地仓库
leodemac-mini:openwebrtc-examples leo$ git remote -v
bamboolsu https://github.com/EricssonResearch/openwebrtc-examples (fetch)
bamboolsu https://github.com/EricssonResearch/openwebrtc-examples (push)
origin https://github.com/bamboolsu/openwebrtc-examples (fetch)
origin https://github.com/bamboolsu/openwebrtc-examples (push)
leodemac-mini:openwebrtc-examples leo$ git branch -a
* master
remotes/bamboolsu/master
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/simpledemo-ios9
检查确认:
leodemac-mini:openwebrtc-examples leo$ gitk
2, patch 操作
-
生成patch
- leodemac-mini:openwebrtc-examples___stefanalund leo$ git format-patch HEAD^
- 生成 0001-modify-for-load-leo-s-page.patch
- git format-patch -s 1bbe3c8c197a35f79bfddaba099270a2e54ea9c7
-
或者使用
git format-patch HEAD^ <==最近的1次commit的patch
git format-patch HEAD^^ <==最近的2次commit的patch
git format-patch HEAD^^^<==最近的3次commit的patch
git format-patch HEAD^^^^ <==最近的4次commit的patch
git format-patch HEAD^^^^^ <==不支持!!!!error!!!
-
使用patch
将补丁打上去。patch -p1 < 0001-Added-liuxingde-test.patch
-
打開 patch 文件, 一開始就看得到 path 的路逕所在.
-p[n] 的 n 值, 只要取消多少條 / 及其左邊的路逕.
以 /usr/src/linux 為例,
若 -p0 就是不取消任何路經
-p1 則將 / 取消, 得 usr/src/linux
-p2 則是將 /usr/ 取消, 得 src/linux
再以 src/linux 為例:
-p0 依然為 src/linux
-p1 則為 linux
如此類推...