github如何处理别人的pull request

建立两个不相干的git仓库之间的连接

在本地git init一个新的仓库,在github或者gitee上创建新的仓库时如何建立连接

git remote -v
git remote add origin https://gitee.com/zhengzy/tzwy.git
git remote -v
git add * 
git commit -am init
git pull origin master --allow-unrelated-histories
git status
git add * 
git commit -am init
git push -u origin master

github如何处理别人的pull request

收到别人的pull request,首先需要pull别人的代码,例如njustwh2014
将Pull Request发出者的派生版本库添加为一个新的源

>git remote add njustwh2014 https://github.com/njustwh2014/spring-boot-redis-guava-caffeine-cache.git

此时版本库中有两个源,一个克隆时自动建立的origin,另外一个就是新增加的njustwh2014。

>git remote -v
njustwh2014     https://github.com/njustwh2014/spring-boot-redis-guava-caffeine-cache.git (fetch)
njustwh2014     https://github.com/njustwh2014/spring-boot-redis-guava-caffeine-cache.git (push)
origin  https://github.com/zheng-zy/spring-boot-redis-guava-caffeine-cache.git (fetch)
origin  https://github.com/zheng-zy/spring-boot-redis-guava-caffeine-cache.git (push)

获取远程版本库njustwh2014的分支和提交。

>git fetch njustwh2014
remote: Enumerating objects: 33, done.
remote: Counting objects: 100% (33/33), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 17 (delta 6), reused 17 (delta 6), pack-reused 0
Unpacking objects: 100% (17/17), done.
From https://github.com/njustwh2014/spring-boot-redis-guava-caffeine-cache
 * [new branch]      master     -> njustwh2014/master

现在除了本地分支master外,还有若干远程分支,如下:

>git branch -a
* master
  remotes/njustwh2014/master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master

此时可以切换到别人pull上来的代码分支,运行或者查看相关代码

>git checkout -b njumaster remotes/njustwh2014/master
Switched to a new branch 'njumaster'
Branch 'njumaster' set up to track remote branch 'master' from 'njustwh2014'.

后面步骤可以上idea上完成更方便

如果pull代码没有问题,可以merge到当前主分支上,提交之后push到自己远程库上,完成本次代码合并

删除本地分支

>git branch -D ngumaster
Deleted branch ngumaster (was 86b127b).

删除添加的远程分支

>git remote remove njustwh2014

参考:http://www.worldhello.net/gotgithub/04-work-with-others/010-fork-and-pull.html#merge-by-hands

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值