Basj Basj - 1 year ago 117
Git Question

How to handle review a pull-request, modify code, and merge?

Let's say I have a repository

on GitHub.

A user named
proposed a pull-request.

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

git checkout -b userblah-test
git pull

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
branch again, but I an error saying that I cannot switch to master because non-committed modifications had been done on the current branch

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
    , such that the user name
    will be registred as contributor of the file

Answer Source

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 (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!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download