Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio: How to create project from existing GitHub repository?

I came from Eclipse background and I am apparently missing something.

There is an existing GitHub project with JS code in it and I would like to start adding TypeScript nature to it, one type at a time.

I have followed this tutorial to clone project from GitHub to my "local git repository". Now the Team Explorer window displays it as local repository and I can commit changes etc but it's not a project and I don't know how to open it as a project (I want to open it as TypeScript project).

The workflow I was used to from Eclipse would simply be New -> Other -> SVN -> Checkout Projects from SVN that is automatically followed by New Project Wizard.

How do I clone existing JS project from GitHub and make it a TypeScrip project while keeping the existing folder structure?

EDIT: I am using Visual Studio Express and I am limited to the native Git extension.

like image 404
daniel.sedlacek Avatar asked Aug 21 '13 16:08

daniel.sedlacek


3 Answers

What I typically do in this situation;

  1. Clone repository using Git in Visual Studio; or use GitHub for Windows and Clone in Desktop from the Git project's web page. This will create a directory (repository) with the project files where you specify.

  2. In visual studio, File->New->create a new project from existing code. From the wizard, select C# or C++ (whatever your choice it does not really matter)

  3. The wizard requires a project file location: give the location of the Git folder that contains the project files (where you cloned the project's repository).

  4. The Wizard requires a unique project name, for example you can use the name of the Git project with VisualStudio (or VS) appended to the end.

  5. Git will now be in sync and you will be able to see all the git files. Making changes will check them out and allow you to push them to the project etc...

***** By default Git will want to check in the newly created .csproj file that Visual Studio creates to allow you to open the project in Visual Studio. You will just want to drag this into the excluded changes section because most likely the project in question will not be using Visual Studio.**

like image 95
Chris Hawkes Avatar answered Oct 20 '22 07:10

Chris Hawkes


I solved this by opening the site as a website. File->Open->Website.

No Project Files/Solution files required. It just opens up the folder in the solution explorer.

To make it a typescript project, just add a tsconfig.json file to the directory.

like image 23
Greg Gum Avatar answered Oct 20 '22 09:10

Greg Gum


Do you have any code in that repository yet that you want to open? I'm guessing not in which case you need to create a new VS project (just like you'd create a new Eclipse project and have it in your workspace)

Go to File, New..., Project... and pick the project type that you want. Give the project a name and set the location to be a folder INSIDE the folder that you cloned your Git repo to earlier (i.e. c:\mycode\mygitproject). Also give your solution a name. A "Solution" in Visual Studio is a wrapper for the projects inside it, kinda like the closest thing to a workspace or a working set in Eclipse but not quite the same thing.

Then Visual Studio should then be smart enough to pick up that this is in Git repo and allow you to commit locally as well as push/pull to GitHub etc.

Finally, while I work with the team that created the Visual Studio Tools for Git, I'd still highly recommend that you get hold of a command line should you want to do some more powerful stuff with Git other than simply committing code, push/pulling changes and branching or merging branches. If you are working against GitHub then you might also want to install GitHub for Windows which will bring some Git tools with it or you can install Git for Windows and also install Posh-Git separately. All of these things work together and give you the maximum power of Git but you can pick and choose the tool that works best for you. You'll probably find a workflow of Clone using GitHub for Windows, commit/push/pull/branch/merge in VS and then Posh-Git if you do more advanced stuff or want to hand-tweak settings.

like image 3
Martin Woodward Avatar answered Oct 20 '22 09:10

Martin Woodward