简体   繁体   English

如何在多个工作目录中使用git?

[英]How do I utilize git with multiple working directories?

I am attempting to use git however am having difficulty understanding how I can use it with multiple working directories for each project. 我试图使用git但是我很难理解如何将它与每个项目的多个工作目录一起使用。 The examples I have found online seem to suggest a single repository. 我在网上找到的例子似乎暗示了一个单一的存储库。

For example I have a directory for each project eg Project A, Project B, etc. These can be located in the same path or different paths eg local drive, network share. 例如,我有一个每个项目的目录,例如项目A,项目B等。这些目录可以位于相同的路径或不同的路径,例如本地驱动器,网络共享。

I would imagine each of the projects has its own repositories. 我想每个项目都有自己的存储库。 Does this mean that each project would require its own .git initialization directory or is the standard and recommendation to use a single git repository? 这是否意味着每个项目都需要自己的.git初始化目录,或者是使用单个git存储库的标准和建议?

Normally, you would set each project up in it's own directory, with it's own repository in it's own .git directory. 通常,您可以将每个项目设置在它自己的目录中,并在其自己的.git目录中拥有自己的存储库。

Git is very light-weight. Git非常轻巧。 You just have the normal project directory, you cd to it, and you do git init , prepare a .gitignore file, do git add . 你只有正常的项目目录,你cd到它,你做git init ,准备一个.gitignore文件,做git add . and then do your first commit. 然后做你的第一次提交。

The .git directory contains zipped versions of all the files in the working directory (sort-of). .git目录包含工作目录中所有文件的压缩版本(sort-of)。 But it won't really save any interesting amount of space to lump several projects together. 但它并没有真正节省任何有趣的空间来将几个项目混为一谈。

The only reason for putting all your projects in the same directory is if you indeed want them all to share version control history. 将所有项目放在同一目录中的唯一原因是,如果您确实希望它们全部共享版本控制历史记录。 If they are truly independent projects, it makes no sense to put them in the same repository. 如果它们是真正独立的项目,将它们放在同一个存储库中是没有意义的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM