How do I merge a pull request on someone else's project in git?

后端 未结 3 2076
难免孤独
难免孤独 2021-01-30 16:10

I cloned this repo on my computer: https://github.com/derobins/wmd.git

There are several bugs with it though, and it looks like another user has fixed them and issued \"

相关标签:
3条回答
  • 2021-01-30 16:40

    (GitHub has very thorough documentation on how to deal with pull requests.)

    Essentially, you'll want to add a remote for the repository of the person who made the pull requests, e.g.:

    git remote add helpful git://github.com/helpful-person/whatever.git
    

    ... then fetch their changes into remote-tracking branches:

    git fetch helpful
    

    ... so that now you have all the commits from that person's GitHub repository in your clone of the upstream repository. If you look at the additional commits within that pull request you could:

    1. merge the latest one, e.g. git merge 75708aeab5
    2. cherry pick each of those changes, e.g. git cherry-pick 2142db89, git cherry-pick 75708aeab5
    3. create a local branch to work on them further, e.g. git checkout -b fix-for-issue3 75708aeab5
    4. etc. etc.

    An alternative is to just clone the repository of the contributor who made the pull requests instead, if that's the same but for those fixes.

    0 讨论(0)
  • 2021-01-30 16:49

    The accepted answer suggests to clone or add remote for the repository of the person who made the pull request. Another cleaner and simpler way is to use this command

    git pull https://github.com/otheruser/repo.git branchname
    

    For example, at the time of writing, ghi has three open pull requests that haven't been merged yet. This is what I did to merge them into my local repo.

    # I want to make sure my master is in sync with the upstream master
    git checkout -b merge-patches master
    # first pull request
    git pull --no-ff https://github.com/TiddoLangerak/ghi.git master
    # second pull request
    git pull --no-ff https://github.com/wayfare/ghi.git master
    

    Note that both pull requests were sent from master that is why I pulled from their master branch.

    This way, other repositories do not get added to your remotes, neither you have to cherry pick or clone them locally.

    0 讨论(0)
  • 2021-01-30 16:56

    You clone the repo to you github account. Then just visit the forkqueue of your cloned repo and choose the patches you want to merge in to your repository.

    0 讨论(0)
提交回复
热议问题