4

I cloned someones github repo, checked out a new branch to isolate changes I was about to make. having modified the code base significantly I realized I should have instead forked the repo and then send out pull request with my changes.

How can I swiftly recover from that as if I were forking the repo from the start?

2
  • 1
    its the same thing...just set the origin to the new location Commented May 29, 2016 at 20:25
  • See github's docs help.github.com/articles/fork-a-repo . The only thing you have to be aware of is that you've done things slightly out of order - but the steps are the same (you create a fork, push to it, and create a pull request). Commented May 29, 2016 at 20:32

2 Answers 2

10

Fork the repo. This will create a clone on GitHub at your user account.

Change the URL of origin to your fork's URL (instead of the original repo):

git remote set-url origin <fork_url> 

Push to origin (your fork), visit your fork's page on GitHub, and there should be a link to compare branches and create Pull Request.

Sign up to request clarification or add additional context in comments.

Comments

0

You can add another remote (usually called upstream) to the source repo. This way there will be a link to original repo, and a few git clients (such as Source code or Git Kraken) can show you progress on original project.

Using this you can also pull changes from original project and push to it, and thus creating a pull request in the process.

Adding a remote is easy:

git remote add upstream <git_url>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.