Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pushing a commit to branch of another user who has opened a pull request

I have a repository on github. My repository is forked by another user. Now he has raised a pull request. I would like to push one commit from my end to his feature branch(for which he has raised a PR). Is this possible.

Here is what I did

git pull remote-ref-other-user feature-branch

After doing this I am able to pull his commits. but when I do some change, add another commit and try to push it this way.

git push remote-ref-other-user feature-branch

I get this error

error: src refspec feature-branch does not match any.
error: failed to push some refs to 'https://github.com/other-user/repo'

Is it possible to push a commit from my side to his branch. If yes then how can it be done.

like image 321
BeginnersSake Avatar asked Sep 12 '25 09:09

BeginnersSake


1 Answers

Say you add his repository, say "mysamplerepository", as a remote:

git remote add johnrepo https://github.com/john/mysamplerepository

And you have your branch called tweaks.

If you want to push your changes to a branch called master in his repository, you would do:

git push <remote-name> <source-ref>:<target-ref>

or in this example:

git push johnrepo refs/heads/tweaks:refs/heads/master

Remember that you also need to have write permission (push access) to push to his repository. You can read more about this on Github's documentation.

like image 76
Samir Aguiar Avatar answered Sep 15 '25 01:09

Samir Aguiar