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
Note: You can get a list of configured remotes and their URLs by running:
git remote -v
Step 2: Fork the project and copy the fork's URL
Step 3: Add the URL to your local copy.
git remote add origin [copied URL]
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)
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!! 😎
Thanks for the comment. It's comments like yours that encourage and motivate people!