Movatterモバイル変換


[0]ホーム

URL:


Skip to content
Search Gists
Sign in Sign up

Instantly share code, notes, and snippets.

@wtbarnes
CreatedMarch 5, 2020 04:49

    Select an option

    Save wtbarnes/56b942641d314522094d312bbaf33a81 to your computer and use it in GitHub Desktop.
    Brief instructions for how to modify and push to someone else's PR on github

    Let's saycontributor has submitted a pull request to your (author) project (repo). They have made changes on theirbranchfeature and have proposed to merge this intoorigin/master, where

    origin -> https://github.com/author/repo.git

    Now say you would like to make commits to their PR and push those changes. First, add their fork as a remote calledcontributor,

    > git remote add contributor https://github.com/contributor/repo.git

    such that,

    > git remote -vorigin      https://github.com/author/repo.git (fetch)origin      https://github.com/author/repo.git (push)contributor   https://github.com/contributor/repo.git  (fetch) contributor   https://github.com/contributor/repo.git  (push)

    Next, pull down their list of branches,

    > git fetch contributor

    and create a new branch (contributor-feature) from the branch that they have created the PR from,

    > git checkout -b contributor-feature contributor/feature

    Now make any changes you need to make on this branch. If you'd like to rebase this PR on top of the master branch ofthe primary repository,

    > git rebase origin/master

    Finally, push the changes back up to the PR by pushing to their branch,

    git push contributor contributor-feature:feature

    Note that if you did a rebase, you'll need to add the--force (or-f) flag afterpush. The author of the PRalso may need to explicitly allow you to push to their branch.

    Helpful Links

    @Blaumaus
    Copy link

    Thank you for this tutorial.

    @edimetia3d
    Copy link

    The author of the PR also may need to explicitly allow you to push to their branch.

    Another note:

    1. It seems only maintainer ofauthor/repo.git could push commit to contributor's branch.
    2. As a contributor, you need to un-check theAllow edits by maintainers box in PR page to disable maintainer's pushing permission, and it is checked by default.

    It bothered me for a while, because someone pushed code into my fork, I just feel somehow strange.

    @Anas-mhameed
    Copy link

    Thank you so much my friend

    @projectkepler-ru
    Copy link

    based

    @stephenwaite
    Copy link

    bradys-panda

    @silverqx
    Copy link

    I thought that's how it works, but it still helped me a lot to get my bearings (orientate). Thx

    @kurtaking
    Copy link

    Still helped me out in 2024. Thanks 😄

    @jbw976
    Copy link

    I've probably used this page like 15-20+ times by now - thank you very much! 🙇‍♂️

    @manio
    Copy link

    Update: it seems this is now outdated, because it is using an HTTPS URL likehttps://github.com/contributor_username/repo.git which was deprecated. Now we have to checkout and push in the SSH URL form like:
    git@github.com:contributor_username/repo.git

    @silverqx
    Copy link

    It's an example only, if you use https or git protocol is up to you, git needs more setup anyway. Is better to use https in examples to not confuse newbies.

    @manio
    Copy link

    @silverqx
    Not exactly: GitHub is not allowing https anymore if you want to push. Doesn't matter if you are newbie or not :)

    remote: Support for password authentication was removed on August 13, 2021.remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.fatal: Authentication failed for 'https://github.com/pavelkomarov/repo.git/'

    That's why I noticed it here because I struggled the same problem today so I thought that it might be worth to notify anyone who is following this "tutorial".

    @silverqx
    Copy link

    Really, I didn't know that, then in this case you are correct, should be updated.

    @kpfleming
    Copy link

    You can still push over HTTPS, you just have to use a Personal Access Token for authentication instead of a username/password combination. I do this all the time, it works fine.

    Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

    [8]ページ先頭

    ©2009-2025 Movatter.jp