- clone fork的分支到本地
git clone https://github.com/lerry903/hutool.git
- 增加源分支(被自己fork的项目)地址到自己git项目远程分支列表中,将原来的仓库命名为upstream,命令为:
git remote add upstream https://github.com/looly/hutool.git
3.核实远程分支列表(optional)
git remote -v
origin https://github.com/lerry903/hutool (fetch)
origin https://github.com/lerry903/hutool (push)
upstream https://github.com/looly/hutool.git (fetch)
upstream https://github.com/looly/hutool.git (push)
核实后,发现不如意,想删除,可以用 git remote remove name
name 为远程分支的命名,如上面例子,可以删除 upstream
git remote remove upstream
或者直接删除之前fork的原始分支 origin
git remote remove origin (直接删除了原始分支后,再fork,也能达到更新了最新代码的需求,后面的步骤就不用了。)
4、fetch源分支的新版本到本地
git fetch upstream
5、合并两个版本的代码
git merge upstream/v4-master
6、将合并后的代码push到github上自己的fork中去
git push origin v4-master