简体   繁体   中英

git adding subdirectories under the main directory

I have a bunch of projects that I want to be put into a directory under the main directory in git. I am sort of new to git and coding, but I looked for an answer on Google and couldn't find anything. Is it possible that you aren't allowed to add subdirectories to git or am I missing something fundamental?

You can create any number of subdirectories in your git repository (main directory).

When you put projects in git repository, you can simply type in git repository:

git add .
git commit -m"comment about my projects"

The best practice is to create one git repo per project.

When you add all your projects in a single git repo, each time you branch or make a tag, that branch or tag will apply to all the projects.
If those projects are tightly coupled (ie, you cannot change one without having to change the others), that can make sense.

If those project can evolve independently one from another, it is best to create one repo per project:

cd /path/tp/project1
git init .
git add .
git commit -m "first commit for project1"
git remote add /url/for/empty/remote/project # GitHub or BitBucket
git push -u origin master

# repeat for project2, ... 
# don't forget to add a README.md per project

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