码迷,mamicode.com
首页 > 其他好文 > 详细

如何同步master的代码到fork分支代码

时间:2017-04-15 18:06:07      阅读:2702      评论:0      收藏:0      [点我收藏+]

标签:origin   original   仓库   命令行   代码   提交   Owner   amp   跳过   

 

同步master的代码到fork分支代码,分三步(remote项目fetch到本地仓库、基于本地master重新创建一个branch、新的branch上commit&push):

1. 项目 fetch 到本地仓库,通过命令行的方式 merge

a. git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
b. git fetch upstream
c. git checkout master(master换成lzc_first_branch,是否可以直接切到lzc_first_branch分支?,从而跳过第二步)
d. git merge upstream/master(master换成lzc_first_branch,是否可以直接merge到lzc_first_branch分支?,从而跳过第二步)

2. 基于本地master重新创建一个branch

 git checkout -b lzc_second_branch master

或者

git checkout master

 git checkout -b lzc_second_branch

3. 基于该lzc_second_branch分支,提交到远程仓库

a.  git commit -a ‘sync codes from upstream‘

b. git push origin master(这个是push到fork之后的远程仓库)

 

那么,有没有办法,直接从remote项目同步到remote的fork分支呢??

 

参考:http://jinlong.github.io/2015/10/12/syncing-a-fork/

 

如何同步master的代码到fork分支代码

标签:origin   original   仓库   命令行   代码   提交   Owner   amp   跳过   

原文地址:http://www.cnblogs.com/liuzc/p/6714965.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!