Reputation: 367
I have forked a repo on github and the repo I have forked from has since added a new branch. I would like to get that branch into my local fork and work on it. Afterwards I would like to commit to that branch (which is in my local fork) and then submit a pull request to the original parent repo.
What ends up happening when I try to do this is as follows
I believe it is trying to push to the parent project new branch and not my fork of it.
How do I get it to let me push to the new branch on my fork so that I can then issue a pull request?
Upvotes: 0
Views: 3261
Reputation: 367
Turns out I should have just searched more (or known better what to search for). This answer solved my problem: Github: Import upstream branch into fork
Upvotes: 0
Reputation: 10292
When you do a git branch -avv, Git will show you which remote branches your local branches are "connected to".
$> git branch -avv
* master a1b2c3d [origin/master] Some commit message here
That [origin/master]
part means that if you update this branch, and attempt a git push
, that's where it'll try to push.
In your case, I'd suggest re-assigning that remote's URL, but for push
only. It seems you're always going to want to fetch
from the parent fork, and push
to your local, correct? If that's the case, then try this:
git remote set-url --push origin [email protected]:YourUser/theRepository.git
This way, when you pull, it comes from the parent fork, and when you push, it goes to your own fork. Then, you use the pull-request mechanism to get your code from your local fork to the parent.
Upvotes: 1