我可以从2个断开连接的目录创建Git存储库吗?

时间:2018-05-08 03:35:02

标签: git web-applications gitignore

我有一个PHP Web应用程序,我想捆绑到GitHub上的Git存储库,但我不清楚如何因为用户界面在webroot中,但模型,控制器,存储等都在外面的文件夹中用于安全目的的webroot。即它看起来像:

C:/inetpub
    |—App_code_directory
    |—Lots_of_unwanted_directories
    |—wwwroot
        |—App_interface_directory
        |—Lots_of_unwanted_directories

我可以直接从两个App目录构建存储库吗?我是否需要将其基于inetpub并创建一个巨大的.gitignore文件?这显然是一种常见的应用程序架构,但我无法用能够产生答案的方式来表达我的网络搜索。

更新:我在下面添加了一个答案,展示了我是如何做到的,这是一个比我原先设想的更有效的.gitignore文件。

2 个答案:

答案 0 :(得分:2)

是的,您可以从两个目录构建一个存储库,并排除Lots_of_unwanted_directories。在这个例子中,你会

  1. cd c:\inetpub
  2. echo "Lots_of_unwanted_directories" > .gitignore
  3. git init .
  4. git add remote origin <your github url here>
  5. git commit . -m "Initial commit"
  6. git push origin master
  7. 但是等等。仅仅因为它可能并不意味着它是一个好主意。您可能希望首先将源代码移动到不同的工作区文件夹中,并将构建文件或任务发布到c:\ inetpub。

答案 1 :(得分:0)

环顾四周并找到如何.gitignore everything except select elements之后,我决定只从我的inetpub目录创建一个存储库,并且只包含我需要的部分。以下是.gitignore看起来的结果。

# Start by excluding everything
*

# Add back in all subdirectories, but not their contents
!/*

# Remove any files within the base directory
*.*

# Add the code base folder contents
!PROJECT_base/**

# Add back in the wwwroot subdirectory
!wwwroot/*

# Remove any files in the wwwroot subdirectory
wwwroot/*.*

# Add the interface folder and contents
!wwwroot/PROJECT/**

# Remove any files from the storage folders
PROJECT_base/storage/uploads/*.*
PROJECT_base/storage/downloads/*.*
wwwroot/PROJECT/downloads/*.*

# Add the stub files back
!**/stub.txt
相关问题