$ git clone -o chucklu https://github.com/chucklu/Hearthstone-Deck-Tracker.githtml
參數說明:git
-o <name>github
Instead of using the remote name origin to keep track of the upstream repository, use <name>.fetch
2.1 $git remote add epix37 https://github.com/Epix37/Hearthstone-Deck-Tracker.gitspa
2.2 $ git remote -v
chucklu https://github.com/chucklu/Hearthstone-Deck-Tracker.git (fetch)
chucklu https://github.com/chucklu/Hearthstone-Deck-Tracker.git (push)
epix37 https://github.com/Epix37/Hearthstone-Deck-Tracker.git (fetch)
epix37 https://github.com/Epix37/Hearthstone-Deck-Tracker.git (push).net
參考如何將本地分支和遠端分支進行映射 orm
$ git branch
chucklu_master
*masterhtm
chucklu_master分支用來對應本身遠端的master分支blog
master分支用來對應原做者的master分支rem
(1)切換到master分支
git checkout master
首先確保目前處於master分支,上面的git branch就是查看本地分支的命令,master前面的*表示當前分支是master分支
(2)同步原做者的代碼
git pull
(3)切換到chucklu_master分支
git checkout chucklu_master
(4)變基或者合併
git rebase master
git merge master
(5)推送代碼到本身的版本庫
git push chucklu HEAD:master或者
git push chucklu chucklu_master:master
假如本身fork版本庫以後,已經在某個分支上進行了修改的話。
那麼rebase就不適用,須要使用cherry-pick來處理。
爲了確保cherry pick以後的代碼,確實是本身所指望的,那麼只須要對比一次,本身的分支的最後一次提交和原做者的分支的最後一次提交,看看差別,是不是本身額外修改致使的
使用tortoisegit-->diff with previous version
使用cherry-pick的注意事項,若是其中有某一個commit是合併致使的,那麼這個commit就不須要進行cherry-pick
今天看到一篇文章,貌似cherry-pick不推薦使用
====9月13日更新====
若是你僅僅是同步原做者的master分支,而不須要進行合併操做的話,本地僅有一個分支也夠用了
不過,須要添加2個remote
擴展:
從新命名遠端git remote rename oldname newname
更多關於操做remote的命令,請參考http://www.ruanyifeng.com/blog/2014/06/git_remote.html