github fork 项目同步上游
虽然github已经在网页上增加了fetch upstream功能,但如果有冲突,只能手动merge.
以下记录一次手动合并的过程:
- clone 自己fork的仓库
1
2
3
4
5
6
7
8♥root-16:47:17->>~/workspace# git clone git@github.com:iEngne/now-subconverter.git
Cloning into 'now-subconverter'...
remote: Enumerating objects: 1514, done.
remote: Counting objects: 100% (121/121), done.
remote: Compressing objects: 100% (110/110), done.
remote: Total 1514 (delta 24), reused 57 (delta 5), pack-reused 1393
Receiving objects: 100% (1514/1514), 46.51 MiB | 991.00 KiB/s, done.
Resolving deltas: 100% (636/636), done. - 确认当前分支是否是要合并的分支,
git brakch -a
,如果不是切换到相应的分支。1
2
3♥root-17:11:23->>~/workspace/now-subconverter# git branch -a
* master
remotes/origin/HEAD -> origin/master - 设置upstream.
1
2
3
4
5
6♥root-16:48:43->>~/workspace/now-subconverter# git remote add upstream https://github.com/zhongfly/now-subconverter.git
♥root-16:51:15->>~/workspace/now-subconverter# git remote -v
origin git@github.com:iEngne/now-subconverter.git (fetch)
origin git@github.com:iEngne/now-subconverter.git (push)
upstream https://github.com/zhongfly/now-subconverter.git (fetch)
upstream https://github.com/zhongfly/now-subconverter.git (push) - 从远程取出upstream
1
2
3
4
5
6
7
8♥root-16:51:20->>~/workspace/now-subconverter# git fetch upstream
remote: Enumerating objects: 32, done.
remote: Counting objects: 100% (32/32), done.
remote: Compressing objects: 100% (20/20), done.
remote: Total 26 (delta 15), reused 17 (delta 6), pack-reused 0
Unpacking objects: 100% (26/26), done.
From https://github.com/zhongfly/now-subconverter
* [new branch] master -> upstream/master - 查看下分支情况,
git branch -a
1
2
3
4
5♥root-17:29:13->>~/workspace/now-subconverter# git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/upstream/master - 执行合并
1
2
3
4
5
6
7
8
9♥root-17:31:27->>~/workspace/now-subconverter# git merge upstream/master
warning: Cannot merge binary files: subconverter/subconverter.exe (HEAD vs. upstream/master)
Auto-merging subconverter/subconverter.exe
CONFLICT (content): Merge conflict in subconverter/subconverter.exe
Auto-merging subconverter/snippets/emoji.toml
CONFLICT (add/add): Merge conflict in subconverter/snippets/emoji.toml
Auto-merging subconverter/pref.example.toml
CONFLICT (add/add): Merge conflict in subconverter/pref.example.toml
Automatic merge failed; fix conflicts and then commit the result. - 查看冲突
1
2
3
4
5
6
7
8
9
10
11
12
13♥root-17:31:44->>~/workspace/now-subconverter# git status
# On branch master
# You have unmerged paths.
# (fix conflicts and run "git commit")
#
# Unmerged paths:
# (use "git add <file>..." to mark resolution)
#
# both added: subconverter/pref.example.toml
# both added: subconverter/snippets/emoji.toml
# both modified: subconverter/subconverter.exe
#
no changes added to commit (use "git add" and/or "git commit -a") - 直接从GUI界面打开文件修改冲突,或者使用
git mergetool
命令从命令行打开merge工具,如果有装VIM默认调用vimdiff. - 修改后commit和push就OK.
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 孑影!
评论