I must mention, this just happened to me this evening on Tuesday 11th February 2020 and I spent about 15 minutes or so working on that.
A friend has been asking me for some code that was just locally on my PC, so after he persisted, I just realised all I could do is put it on Github for him to find.
For those that don't know how to push a local project to GitHub, hopefully, these following can help:-
- Go to your GitHub account on your browser, login(if you aren't logged in).
- Create a repository with the same name as that of your local project e.g cats
- Open your terminal & browse to your project directory e.g
lailah@DESKTOP-VDD8TTR:/mnt/e/ikowapi$
then do the following commands
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/lailahgrant/cats.git
git push -u origin master
Now back to our main question!!!
let's say
instead of the above, you end up doing the following,
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/lailahgrant/cat
git push -u origin master
I know this can happen because it happened to me today and this is what I did :-
lailah@DESKTOP-VDD8TTR:/mnt/e/ikowapi$ git remote add origin https://github.com/lailahgrant/ikowap
lailah@DESKTOP-VDD8TTR:/mnt/e/ikowapi$ git push -u origin master
Username for 'https://github.com': lailahgrant
Password for 'https://lailahgrant@github.com':
remote: Repository not found.
fatal: repository 'https://github.com/lailahgrant/ikowap/' not found
Then after realising my mistake, I now tried to put the correct URL and I got the following errors:-
lailah@DESKTOP-VDD8TTR:/mnt/e/ikowapi$ git remote add origin https://github.com/lailahgrant/ikowapi.git
fatal: remote origin already exists.
At this point I was so desperate & I tried every solution in the --help but all in vain.
I finally got a solution from the popular saviour - Stack overflow and all I did was run the following:-
lailah@DESKTOP-VDD8TTR:/mnt/e/ikowapi$ git remote rm origin
The above command removed all the remote origin URLs I had put.
Now it was safe for me to run the other commands...
lailah@DESKTOP-VDD8TTR:/mnt/e/ikowapi$ git remote add origin https://github.com/lailahgrant/ikowapi.git
lailah@DESKTOP-VDD8TTR:/mnt/e/ikowapi$ git push -u origin master
Username for 'https://github.com': lailahgrant
Password for 'https://lailahgrant@github.com':
Counting objects: 185, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (180/180), done.
Writing objects: 100% (185/185), 1005.56 KiB | 3.63 MiB/s, done.
Total 185 (delta 32), reused 0 (delta 0)
remote: Resolving deltas: 100% (32/32), done.
To https://github.com/lailahgrant/ikowapi.git
* [new branch] master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
lailah@DESKTOP-VDD8TTR:/mnt/e/ikowapi$
Hopefully you found this helpful, Thanks for reading through
Top comments (11)
Thanks for this..
🤗🤗🤗thank you everyone for your feedback. I’m humbled. 🎈🎈
Thank you!
Perfect👌🏾
Awesome 🎉
Thanks for that
Wow, this could happen to anyone, thanks a bunch .
You’re welcome dear, thanks for your time
Awesome lilian 🤾♀️🎉🎉
THANK YOU!
Спасибо, помогло