[英]Need help setting up new multi project Git local repository with existing code
I was using Perforce and am switching computers and decided to try Git.我正在使用 Perforce 并且正在切换计算机并决定尝试 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.此外,我希望 Git 存储库位于单独的文件夹中。
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.
我可能只是将此目录返回到 OneDrive,或者让 OneDrive 指向 Git 存储库。
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
. Robotx
有我想在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
.我想做的是为
Source
、 EE
和ME
目录中的每个Robotx
以及Library
有单独的提交历史。 I don't want to use filters to separate them out.我不想使用过滤器将它们分开。
Finally, I want the git repository to be at c:\Depot\Git
最后,我希望 git 存储库位于
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. 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
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
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
环境变量或在命令行中指定--git-dir
:
git --git-dir=C:\Depot\Git ...
And you can add submodules only if you have already Git repositories for each of your projects.只有当您的每个项目已经拥有 Git 存储库时,您才能添加子模块。
I would start simple first: simply git init
in each of your project, and start adding new commits in your repositories.我会先从简单的开始:在您的每个项目中简单地启动
git init
,然后开始在您的存储库中添加新的提交。
Once you have added commits and pushed those projects to a remote location, then you can start testing submodules.添加提交并将这些项目推送到远程位置后,您就可以开始测试子模块了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.