简体   繁体   中英

Create a repository tree on my server working with GIT

I could not find what I was looking for by searching with google because I can't figure any keywords that would lead me to an answer.

I started with GIT recently, I use my own server, not the online one : you need to pay to be private. Following this tutorial :

https://github.com/msysgit/msysgit/wiki/Setting-up-a-Git-server-on-Windows-using-Git-for-Windows-and-CopSSH

I used this command :

git init --bare

Everything works just fine, for one project. But i have hundred projects... categorised in 3 section : Web,Desktop, Others.

So i'm currently thinking of :

  1. Making myself all the folder tree on the server and repeat the above command inside every single final folder. I know this will work, since it work for one project, but sure will be long.

  2. Try to git in my whole folder tree at once... I assume this will fail since there is too much files, probably going to be heavy and I don't know how git will understand what I want to do anyway, I think it will cause push problems.

  3. Search for some built-in GIT command that divide the repository to make a folder tree like to one I have localy.

I'm sure someone did this before, I don't want to begin something and later realize it could have been much simpler...

What is the common GIT way to start up when you already have a lot of projects ?

Have a single git repository for hundreds of projects would make collaboration effort very difficult, as the commit logs would be aggregated for all project. I would not recommend this.

Assuming you have a collection of projects (P1, P2,..) under MyGitRepo you could automate the process.

MyGitRepo
|..P1
|..P2
|..
\..PN

You can run the command git init --bare in each of the project as follows from Powershell

Get-ChildItem -Path C:\\MyGitRepo -Directory -Depth 0 | Foreach {echo $_.fullname; cd $_.fullname; git init --bare}

  • Get-ChildItem - List Items
    • -Path - Where to search
    • -Directory - Return only directory
    • -Depth - return only sub-folders and don't recurse
  • Redirect output to Foreach
    • echo the subfolder
    • cd - change directory/enter directory
    • git ... - execute command in directory

Incase you have a folder structure as you mentioned

MyGitRepo
|..Web
   |..W1
   \..W2
|..Desktop
   \..D1
|..
\..Others
   \..O1

Get-ChildItem -Path C:\\MyGitRepo\\*\\* | Foreach {echo $_.fullname; cd $_.fullname; git init --bare}

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