简体   繁体   中英

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. 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.

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?

Normally, you would set each project up in it's own directory, with it's own repository in it's own .git directory.

Git is very light-weight. You just have the normal project directory, you cd to it, and you do git init , prepare a .gitignore file, do git add . and then do your first commit.

The .git directory contains zipped versions of all the files in the working directory (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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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