How to clone to Github

Hello everybody,

I tried to clone a repository to Github to easierly ask a question about the project.

So, in Github Desktop, I opened the project, and then selected File, Clone Repository.

I gave my pseudo and the name of the project for the repository, I swear it did not exist.

Well, this was a problem, I was said Github can only clone to an existing repository.

I connected to on the browser, and created the repository. In the list, it shows “0 bytes”. Well, I shall not nitpick for the s.

I came back to Github Desktop, and asked again to clone the repository to

Well, impossible : the repository contains files, Github can only clone to an empty repository.

So, it was impossible to clone before creating the repository, and it was impossible to clone after doing so.

Well, you mean I must clone during the repository creation on the website ?

Can somebody explain with a little more details how to do that ?

You know what, I tried clicking on the + in the upper right corner of the web page, import repository, and was answered “We can’t import from file:///D:/Projets%20Visual%20Studio/Winform/Tension/.git. Please check the URL and try again”

Well, I checked the URL (Firefox displayed the project with it) and tried again, but it did not work better.

It’s a little unclear what you’re trying to do. “Cloning” means there is a repository on GitHub, and you are making a copy on your local machine. It sounds more like you are starting off with a repository on your local machine, and you want to “publish” it up to GitHub?

If that’s the case, these are the instructions you want to follow:

Thank you.
In fact, I used the command line to backup to a new repository on GitHub, the difficulty was to be sure, not to change the “distant” repository previously configured on the project.
But it turns on this is not that a big problem, as Git is able to manage two external repositories, and by default, with Visual Studio Team Explorer interface, push to the first one.
I did that some weeks ago and am not yet quite sure to be able to do it again at first try without errors, but it seems it is possible to get what I wanted to obtain.

Ah, it sounds like you’re talking about pushing to multiple “remotes”.

In GitHub Desktop, here’s how you would swap out the remote URL to push to a different repository:

You mean it is possible to attach several distant repositories, like that ?
But when you arrive there, you have the repository you gave the previous time, no ?
If you type another path, does not it replace the previous one ?

Yes, if you collaborate with others (who have their own copies of the repository) or use multiple computers it’s actually fairly common to have multiple remotes on one repository. Each remote has a unique name, so you can select which to use on operations like push, fetch, or pull.

Changing the URL for a remote is also possible. Which makes sense in your case depends on whether you want to keep using both remotes, or just switch from one to the other permanently.

I personally can’t say how to work with multiple remotes in GitHub Desktop though, because use the command line.

Well I tried to fully rely on Visual Studio, Team Explorer, for the synchronization of repositories, but it seems it was not that simple.
I spent a little time to have a script to generate two synchronized repositories, but … after a few modifications on the code, it appears an intervention is sometimes necessary with the command line.
So, for the moment being, each time I search the error message I obtain, to know what command line to type. And sometimes, I have to do two or three attempts.
I have got to take note of what happens, when, and what command line I typed, with what results. I presume after a few months like that I can eventually obtain something cleanly automatized.

1 Like