How to push to your repo a repository from a coding test
Who never had a coding test to do from a big company to be able to check out if you are able to code? I had to do that for a big company. My problem was that they send me a repository per email with all git and github already initialized. Meaning I was not able to send it out to my own repository on Github and show to the world what I was able to do.
I will show you how to do change that, and don’t worry it’s really simple.
1- What is my problem
When I was on my folder and tried to push it to my repository on Github with the command git push origin master I got the response
$ git push origin master
ssh: connect to host git.rea*** port 22: Operation timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.This meant that my folder was still connected to the previous owner.
2- How to check that?
To check the owner of the repository simple check it out with this command
$ git remote -v
here is my result:
origin git@git.rea***:recruiting/toy-robot.git (fetch)
origin git@git.rea***:recruiting/toy-robot.git (push)3- how to fix this?
3-1 Trouble to fix it!
I tried to fix it by simple adding my repo on the remote like this:
$ git remote set-url origin git@github.com:JodyVanden/toyrobot.git
$ git remote -v
origin git@github.com:JodyVanden/toyrobot.git (fetch)
origin git@github.com:JodyVanden/toyrobot.git (push)Then I created the repository on Github with
$ hub create
but this did not really worked out for me with an error:
$ git push origin master
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.3-2 How I did to fix it
I finally found out that I had to remove the previous remote with this command line:
$ git remove rm origin
and then add my remote with creating a folder on github
hub create
You can then double check if everything is ok
$ git remote -v
$ git remote -v
origin git@github.com:JodyVanden/toyrobot.git (fetch)
origin git@github.com:JodyVanden/toyrobot.git (push)Everything is looking good.
I just need to push it to my Github with
git push origin master
Counting objects: 375, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (333/333), done.
Writing objects: 100% (375/375), 39.99 KiB | 356.00 KiB/s, done.
Total 375 (delta 140), reused 21 (delta 5)
remote: Resolving deltas: 100% (140/140), done.
To github.com:JodyVanden/toy-robot.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.some links where I found the infos: Stackoverflow / Stackoverflow 2 / Githubhelp