如何将现有的visual studio项目添加到空的git存储库中(How to add existing visual studio project to empty git repository)

编程入门 行业动态 更新时间:2024-10-22 23:09:14
如何将现有的visual studio项目添加到空的git存储库中(How to add existing visual studio project to empty git repository)

我在服务器上有一个空的git存储库,我可以使用git clone克隆到我的本地机器。 我的问题是,如何在该回购中添加一个新的visual studio 2010项目? 具体来说,我创建了一个文件夹,并将其命名为“repos”。 在文件夹中,我在git bash上运行以下命令来克隆我的空repo-git clone(伪代码),它在我的“repos”文件夹中创建一个名为EmptyRepo的文件夹。 现在,如果我想创建一个新的Visual Studio项目,我会在这个EmptyRepo文件夹中创建它吗? 在这种情况下,如果我正在创建名为GitTrial的WindowsForm项目,我的目录看起来像 - > repos / EmptyRepo / GitTrial / GitTrial.sln ,这将是我的解决方案文件,和 repos / EmptyRepo / GitTrial / GitTrial /将包含一堆文件,如bin,obj,Properties,Form1.cs,Form1.Designer.cs,GitTrial.csproj,Program.cs 或者这些文件会放在不同的文件夹中吗?

另外,在这些路径中,.gitignore文件会去哪里? 谢谢!

I have an empty git repository on the server which I can clone to my local machine using git clone. My question is, how do I add a new visual studio 2010 project to that repo? Concretely, I created a folder and named it "repos". Inside the folder, I run the following command on git bash to clone my empty repo - git clone (pseudo-code), which creates a folder called EmptyRepo inside my "repos" folder. Now if I want to create a new Visual studio project, would I create it inside this EmptyRepo folder? In which case if I'm creating a WindowsForm project named GitTrial, my directory would look like -> repos/EmptyRepo/GitTrial/GitTrial.sln, which would be my solution file, and repos/EmptyRepo/GitTrial/GitTrial/ would contain a bunch of files like bin, obj, Properties, Form1.cs, Form1.Designer.cs, GitTrial.csproj, Program.cs Or would these files go in a different folder?

Also, inside these paths, where would the .gitignore file go? Thanks!

最满意答案

任何repos/EmptyRepo/ contains都可以添加到EmptyRepo存储库中,所以是你建议的repos/EmptyRepo/GitTrial/...可以正常工作。

在将文件添加到repo之前,我首先建议在repos/EmptyRepo/.gitignore创建.gitignore文件,在该文件中可以忽略特定于用户和生成的Visual Studio文件。 这是一个包含建议的Visual Studio .gitignore 的公共.gitignore存储库 。

接下来,使用git add添加要包含在存储库中的任何文件。 例如: git add GitTrial/GitTrial.sln以添加单个文件,或者git add GitTrial以添加整个目录及其子目录,不包括.gitignore中的目录。

最后, git commit您的更改和git push git commit到远程EmptyRepo存储库。

Anything that repos/EmptyRepo/ contains can be added to the EmptyRepo repository, so yes your suggested placement of repos/EmptyRepo/GitTrial/... would work fine.

Before adding files to the repo, I first recommend creating a .gitignore file at repos/EmptyRepo/.gitignore, in which you can ignore user-specific and generated Visual Studio files. Here is a public .gitignore repository that contains a suggested Visual Studio .gitignore.

Next, use git add to add whatever files you want to include in the repository. Ex: git add GitTrial/GitTrial.sln to add an individual file, or git add GitTrial to add the entire directory and its children, excluding those in the .gitignore.

Lastly, git commit your changes and git push to the remote EmptyRepo repository.

更多推荐

本文发布于:2023-08-06 16:49:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1452849.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何将   库中   项目   studio   repository

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!