dimanche 12 avril 2015

Git: Add directory from different location

Say I have Visual Studio Projects in "C:\Projects", so a typical filesystem tree would look like this:



C:\Projects
├MyProject1
│├MyProject1.sln
│├SubProject1
││└SubProject1.vbproj
│└SubProject2
│ └SubProject2.vbproj
└MyProject2
├MyProject2.sln
└SubProject1
└SubProject1.csproj


Now I would like to create a Git repository which contains the MyProject2-directory and its contents. The obvious approach: Use C:\Projects\MyProject2 as the repository-directory. The problem is that git will ad the .git-directory and the .gitattributes- and .gitignore-files next to the MyProject2.sln-file and the subproject-directories:



C:\Projects
└MyProject2
├MyProject2.sln
├.gitattributes
├.gitignore
├.git
│└Some other stuff
└SubProject1
└SubProject1.csproj


I do not want that to happen because it clogs up the project directory.


Another approach would be to move the MyProject2-directory 1 level deeper:



C:\Projects
└MyProject2
├.gitattributes
├.gitignore
├.git
│└Some other stuff
└MyProject2
├MyProject2.sln
└SubProject1
└SubProject1.csproj


But I can't do that because lots of other projects have static path references to C:\Projects\MyProject2\SubProject1\bin\Release\SubProject1.dll and it would break them all to move this project. Not to mention the custom item- and project-templates for Visual Studio.


My goal is to create a separate directory C:\Repositories with a sub-directory MyProject2 which contains the .git-directory and the .gitattributes- and .gitignore-files and somehow link it to the project in C:\Projects:



C:
├Projects
│└MyProject2
│ ├MyProject2.sln
│ └SubProject1
│ └SubProject1.csproj
└Repositories
└MyProject2
├.gitattributes
├.gitignore
└.git
└Some other stuff


Preferably I'd like the complete Git repository to contain a single directory MyProject2 which contains the MyProject2.sln-file and other directories (as opposed to the repository directly containing the MyProject2.sln-file and other directories).


I am using Github for Windows. I am ok with using the console to setup the repository, but a solution where I have to use the console every time I want to do a commit is not acceptable.


Aucun commentaire:

Enregistrer un commentaire