1

I was using Perforce and am switching computers and decided to try Git. I have several projects - source code, electrical engineering files, mechanical engineering files, etc. I would like to keep their commits separate. I also want to be able to tag different commits so that I can get back to a particular configuration (for lack of a better term).

In addition, I want the Git repository to be in a separate folder.

I do not expect to be sharing the code with an online repository or other people. So, I was going to create a local repository and add/commit to it. I'll probably just back this directory to OneDrive or have OneDrive point to the Git repository.

I've read many different blogs and questions but am at a loss on how to proceed and would be very grateful for guidance.

The directory structure is as follows:

c:\Depot c:\Depot\Source c:\Depot\Source\Robot1 c:\Depot\Source\Robot2 c:\Depot\Source\Robot3 c:\Depot\Source\Library c:\Depot\EE c:\Depot\EE\Robot1 c:\Depot\EE\Robot2 c:\Depot\EE\Robot3 c:\Depot\ME c:\Depot\ME\Robot1 c:\Depot\ME\Robot2 c:\Depot\ME\Robot3

Each of the "leaf" directories - ex. Robotx have further sub-directories that I want to track within Robotx.

What I'd like to do is have separate commit histories for each of the Robotx in the Source, EE and ME directories and also for Library. I don't want to use filters to separate them out.

Finally, I want the git repository to be at c:\Depot\Git

I went to c:\Source and did: git init --separate-git-dir Git and that created c:\Source\Git with what seemed like Git files and folders.

To add the first project, I went to c:\Depot\Source and did: git submodule add `pwd`/Robot1 and I got an error message: 'Source/Robot1' already exists and is not a valid git repo

1 Answers1

0

Once you have created a Git repository in a separate folder, you need to set your GIT_DIR environment variable or specify --git-dir in your command line:

git --git-dir=C:\Depot\Git ...

And you can add submodules only if you have already Git repositories for each of your projects.

I would start simple first: simply git init in each of your project, and start adding new commits in your repositories.
Once you have added commits and pushed those projects to a remote location, then you can start testing submodules.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thank you. If I understand the second answer at [link](https://stackoverflow.com/questions/505467/can-i-store-the-git-folder-outside-the-files-i-want-tracked), with a current version of git, a .git file is created such that this option isn't required? – Harjit Singh Nov 15 '19 at 21:21
  • Yes, you can reference the path of the Git repository that way too. – VonC Nov 15 '19 at 22:44