DEV Community

Cover image for Uh Oh! I Cloned without Forking!
Upamanyu Das
Upamanyu Das

Posted on


Uh Oh! I Cloned without Forking!

Last week I cloned a repo without forking it first and only realised my mistake after I had already made some commits to my local copy.

Rookie mistake!

But there's an easy fix.

Step 1: Remove the existing remote from your local repo.

git remote remove origin
Enter fullscreen mode Exit fullscreen mode

Note: You can get a list of configured remotes and their URLs by running:

git remote -v
Enter fullscreen mode Exit fullscreen mode

Step 2: Fork the project and copy the fork's URL

Copy fork's URL

Step 3: Add the URL to your local copy.

git remote add origin [copied URL]
Enter fullscreen mode Exit fullscreen mode

And you're done 😀 ! You can now push your code and it will go to your fork.

Hope this was helpful!

Hi, I am Upamanyu!

If you liked this post maybe you'll like my tweets too. Follow me @tintin_das 🐦.

Top comments (2)

bigt1305 profile image
Anthony Hoss

Thank you; I do use Git quite a bit, and have made mistakes like this. It's always nice to have a little explanation (aka, not too long, and not just 5 words) to help fix these little errors. Thanks for the quickie!! 😎

tintindas profile image
Upamanyu Das

Thanks for the comment. It's comments like yours that encourage and motivate people!

Advice For Junior Developers

Advice from a career of 15+ years for new and beginner developers just getting started on their journey.