Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to submit a pull request from a cloned repo?

How to submit a pull request from an existing locally-cloned repo?

Often, I want to look at some libraries source code from github, so I clone it. Later, I discover some issue with the code and raise it on a mailing list, often in passing. The library author says "nice find, can you send a pull request?".

And the answer is "not that easily". I haven't forked the repo yet, Ive cloned it. And there doesn't seem a way I can find to submit a pull request from a cloned repo?

If this limit is true, it feels like the sensible reaction is to fork anything and everything you ever look at, just so that if you ever might want to contribute, you can. And that fills up your github account with many inactive forks.

Doesn't seem a lot of talk about this issue - am I the only person whom this problem affects?

like image 480
Ben Hutchison Avatar asked Feb 16 '13 02:02

Ben Hutchison


People also ask

Can you make a pull request from a clone?

Fundamentally, pull requests are the mechanism for contributing to a group project. Pull requests happen when you fork/clone a project, make changes to the codebase or add a feature, or do other work, and then are ready to merge your improvements back into the master branch on the main repository.


1 Answers

Fork the repo on GitHub, then add your fork repo as a remote to your local cloned copy:

git remote add myfork https://github.com/<myGitHubAccountName>/<repoName>.git 

Then you can push to your fork:

git push myfork master 

If you're doing more than just this one pull request, you can remove the origin remote and name your fork as origin:

git remote rm origin git remote add origin https://github.com/<myGitHubAccountName>/<repoName>.git 

This is typically what I do. Sometimes I add the original origin as upstream so I still have a reference to it.

like image 53
bobthecow Avatar answered Oct 02 '22 13:10

bobthecow