git 怎么查看合并过来哪些代码,如何处理查看拉取请求,修改代码并合并?

Let's say I have a repository myproject on GitHub.

A user named userblah proposed a pull-request.

I tried the following, in order to test his modifications :

git checkout -b userblah-test

git pull https://github.com/userblah/myproject.git

Then I had access to his version in my folder, this is ok.

Then I decided to modify a few things in his code : I opened the code in text editor, did some modifications and saved.

Then I wanted to switch to my master branch again, but I an error saying that I cannot switch to master because non-committed modifications had been done on the current branch userblah-test.

What are the correct commands to handle of a pull-request properly?

I mean :

Pull the user's code into a new branch

Modify his code a little bit according to my tastes

Push this in my master, such that the user name userblah will be registred as contributor of the file

解决方案

I think you're probably looking to perform a merge, which will take changes from one branch, and 'merge' (combine) them with changes on another.

Assuming you want to make changes to the proposed code:

git checkout -b userblah-test (checks out a new branch named userblah-test)

git pull https://github.com/userblah/myproject.git (pull in proposed changes from userblah)

Make your changes

git add . (the . adds all modified files)

git commit (commits the changes - it's important to note that you are committing your changes to the current branch only, i.e userblah-test)

git checkout master (checks out master branch before merging)

git merge userblah-test (merges all changes made on userblah-test with current branch)

However, if the pull request has been submitted through GitHub, I suggest you inform the original author about changes that you would like to make in the pull request comments. The author should be willing to make these changes themselves and add them to the pull request. You can then merge his PR in using GitHub's own web interface - see here for more info.

Pull requests are intended to promote discussion around code, if you're not 100% happy with the changes this person has proposed - tell them!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值