0

I have an upstream project which I have forked. I created a new branch on my local and made changes to it. Now I wish to push to a branch upstream so my friend can see it. Can I push code that I changed in my own fork to a branch in the upstream by passing pull requests? Do I need to create a branch in my upstream first? How do I accomplish this?

I have tried:

git push upstream my-upstream-branch

which resulted in:

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

I have all of my code checked in.

I also tried to create a new branch from the upstream branch and got

git checkout -b shell-ui upstream/shell-ui
fatal: 'upstream/shell-ui' is not a commit and a branch 'shell-ui' cannot be created from it
afriedman111
  • 1,925
  • 4
  • 25
  • 42
  • 1
    Does this answer your question? [Message 'src refspec master does not match any' when pushing commits in Git](https://stackoverflow.com/questions/4181861/message-src-refspec-master-does-not-match-any-when-pushing-commits-in-git) – wotanii Nov 26 '19 at 16:58
  • I already tried that. It doesn't work. – afriedman111 Nov 26 '19 at 17:00

2 Answers2

1

You need push the branch with change to your forked repo or to upstream repo first.

  • To push your branch to your forked repo git push --set-upstream origin branch_name

  • To push to upstream repo git push --set-upstream upstream branch_name

And then you can create a pull request.

If you have pushed to the branch to your forked repo, then you need to create a pull request from new branch of the forked repo to the main branch of the upstream repo

If you have pushed to the branch to upstream repo, then you need to create a pull request from the new branch in upstream to the main branch of upstream

Esha
  • 151
  • 8
0

If you want to open a PR in the upstream you'll only need to:

  1. Fork the upstream & create a new branch to work on locally;
  2. Push your local changes to your remote forked repo;
  3. Access the upstream repo page and then Compare & pull request*.

*You'll see something like the shown here.

Gabriel Melo
  • 461
  • 3
  • 8
  • Pull request gives an option to merge it to the master from the branch. How do send the branch as it is and also push future changes from the branch in forked repo to upstream's same branch? – Sudhir Singh Khanger Mar 04 '20 at 06:24