If the desired repository already exists (perhaps on GitHub) then you can clone it to your local system, and then copy the solution directory into it. Then add the files, commit the files, and push the local. This put the solution in a repository.
为了将一个没有源代码控制的现有项目放到一个现有的 EMPTY (这很重要) GitHub 存储库中,这个过程很简单,但是很棘手,因为你的第一个倾向是使用 Team Explorer,这是错误的,这就是为什么你会有问题。
首先,将它添加到源代码控制中。上面有一些解释,每个人都能做到这一点。
Now, this opens an empty LOCAL repository and the trick which nobody ever tells you about is to ignore the Team Explorer completely and go to the Solution Explorer, right click the solution and click Commit.
Then I copied my existing project files into this repository.
增加了一个 .gitignore文件。
准备并提交所有文件。
推送到远程存储库。
It would be interesting to see this all done directly in Visual Studio 2015 without tools like Git Extensions, but the things I tried in Visual Studio didn't work (添加到源代码管理 is not available for my project, adding a remote didn't help, etc.).
这样做的实质是通过 Visual Studio 创建所有的附加功能来执行“ git init”(相应地设置忽略文件,如忽略用户特定文件、临时文件、目录等)。
Essentially your git repository has been created correct locally (this is the major step with VS project since this folder contains a lot of files that we want to ignore).
I start Git Bash session now in this working directory and since I use BitBucket, I follow the instructions given there (just copy the lines below from there).