如何处理查看拉取请求,修改代码并合并? [英] How to handle review a pull-request, modify code, and merge?

查看:246
本文介绍了如何处理查看拉取请求,修改代码并合并?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我在GitHub上有一个仓库 myproject



一个名为 userblah 提出了一个拉取请求

我尝试了以下方法来测试他的修改: p>

  git checkout -b userblah-test 
git pull https://github.com/userblah/myproject.git

然后,我可以访问我的文件夹中的他的版本,这很好。 / p>

然后我决定在他的代码中修改一些东西:我在文本编辑器中打开了代码,做了一些修改并保存。



然后我想再次切换到 my master 分支,但是出现一个错误,说我无法切换到master,已经对当前分支 userblah-test 执行了修改。



什么是正确的命令我的意思是:


  1. 将用户代码拉入新分支

  2. 根据我的口味修改他的代码

  3. 在我的 master ,这样用户名 userblah 将被注册为文件的贡献者


解决方案

我认为您可能正在执行合并,它将从一个分支中进行更改, 'b'b

假设你想修改建议的代码:




  • git checkout -b userblah-test (检出一个名为userblah-test的新分支)

  • git pull https://github.com/userblah/myproject.git (从userblah提取建议的更改)

  • 制作您的更改

  • git add。(the。添加所有已修改的文件)

  • git commit (提交更改 - 重要的是要注意您将更改提交到当前分支只有,即 userblah-test

  • git checkout master (合并之前的master分支)

  • git merge userblah-test (合并对 userblah-test 与当前分支)

  • 但是 GitHub,我建议你告诉原作者关于你想在拉请求评论中做出的改变。作者应该愿意自己做出这些更改并将其添加到请求中。然后,您可以使用GitHub自己的Web界面合并他的PR - 请参阅此处获取更多信息。



    如果您对这个人提出的改变不满意,那么拉取请求的目的是促进围绕代码的讨论 - 告诉他们! / p>

    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 :

    1. Pull the user's code into a new branch
    2. Modify his code a little bit according to my tastes
    3. 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:

    1. git checkout -b userblah-test (checks out a new branch named userblah-test)
    2. git pull https://github.com/userblah/myproject.git (pull in proposed changes from userblah)
    3. Make your changes
    4. git add . (the . adds all modified files)
    5. 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)
    6. git checkout master (checks out master branch before merging)
    7. 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!

    这篇关于如何处理查看拉取请求,修改代码并合并?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆