git 解决自己fork的代码和源码的冲突

在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到自己的远程代码库了。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值