Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I turn a git clone into a fork and then push to heroku from the fork?

I cloned a repository thinking I wouldn't need to change anything. Now I want to change something.

I forked the code on github but now I'm unsure what to do next. I don't want to make the changes and then then accidentally commit to the repo I cloned from.

like image 544
pixelfairy Avatar asked Jul 17 '14 18:07

pixelfairy


1 Answers

Your local git repository determines where to push / pull based on "remotes". Right now, your local repository two remotes, origin (which right now points to the Github repository you cloned) and heroku (which points to a Heroku repository).

You forked the origin to a new repository on Github; let's say the the old one was https://github.com/bob/website.git and your fork is https://github.com/pixelfairy/website.git.

If you do

git remote -v

You should see something like

origin  https://github.com/bob/website.git (fetch)
origin  https://github.com/bob/website.git (push)
...

We can change this so that origin points to your fork. Do

git remote set-url origin https://github.com/pixelfairy/website.git

Now git remote -v should output

origin  https://github.com/pixelfairy/website.git (fetch)
origin  https://github.com/pixelfairy/website.git (push)
...

You can now push and pull as you did before, and it will use your fork instead of the originally cloned repository.

like image 182
tbekolay Avatar answered Oct 13 '22 06:10

tbekolay