06月27, 2020

git: 保持fork的项目与上游同步

与另一个仓库的分支合并

添加上游仓库:

git remote add upstream [upstream_url]

fetch 之:

git fetch upstream

切换到本地master分支:

git checkout master

拉取远程分支的修改

$ git branch -r
origin/HEAD -> origin/master
origin/daves_branch
origin/discover
origin/master

$ git fetch origin discover
$ git checkout discover

将upstream/master merge到 本地master分支:

git merge upstream/master

同时别忘了push到自己的github仓库:

git push origin master

How to resolve ‘fatal: refusing to merge unrelated histories’

Use ‘–allow-unrelated-histories’ One way to solve the issue is to use the --allow-unrelated-histories git flag.

Here the git command will look something like this:

git pull origin master --allow-unrelated-histories.

本文链接:http://57km.cc/post/git: bao-chi-fork-de-xiang-mu-yu-shang-you-tong-bu.html

-- EOF --

Comments