在github上自己fork下来的代码pull到本地后进行了修改,后来upstream的代码更新,和自己改过的部分有冲突。可以用git命令行解决冲突,在pull下来的代码位置,点击右键,打开Git Bash:
查看原有远程分支信息

git remote -v
git fetch upstream
git merge upstream/master

在merge时如果提示冲突:

Auto-merging allennlp/training/trainer.py Auto-merging
allennlp/commands/train.py CONFLICT (content): Merge conflict in
allennlp/commands/train.py Automatic merge failed; fix conflicts and
then commit the result.

则先解决代码中的冲突,我是用的VSCode,选择用他们的还是自己的代码,然后add,commit:

 git add .
git commit -m "my"

然后再次尝试merge(实际不需要):

git merge upstream/master

提示

Already up to date.

说明解决了冲突,现在可以push到自己的远程代码库了。

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐