2

For an IC design class I am taking we have to VNC into a linux server to access the tools and design out circuitry and test benches. Originally I just had one repository that I was pushing everything to but we have started working on a project in groups and the best way to distribute the designs among everyone appears to be through Git. I need a way to separate my class directory into two separate repositories.

File Structure

class
├── Lib
|   ├── inverter
|   ├── nand2
|   ├── nor2
|   └── proj
└── LibTest
    ├── inverter
    ├── nand2
    ├── nor2
    └── proj

Desired Project Repository

class
├── Lib
|   └── proj
└── LibTest
    └── proj

Desired Lab Repository

class
├── Lib
|   ├── inverter
|   ├── nand2
|   └── nor2
└── LibTest
    ├── inverter
    ├── nand2
    └── nor2

I can't really find a way to make this happen unless maybe I have my main repository in the class directory and create two separate repositories for Lib\proj and \LibTest\proj but I would really like it if the two project directories were tied together, as if they were in the same repository.

Update

2016-12-02 02:10 PM CST

Okay, so I setup two separate git repositories within class and renamed them to .gitproj & .gitlab.

git init
mv .git .gitlab
git init
mv .git .gitproj

I then modified the /info/exclude file to exclude those directories and isolate the lab directories within the lab repo and the proj directory within the proj repo.

.gitlab/info/exclude

# Ignore git directories
.git*
!.gitignore

# Ignore project directories
Lib/proj
LibTest/proj

.gitproj/info/exclude

# Ignore git directories
.git*
!.gitignore

# Ignore everything under Lib and LibTest
Lib/*
LibTest/*

# Unignore proj directories
!Lib/proj
!LibTest/proj

Finally, I added aliases to my .bashrc file. Using Git-Bash for Windows it was the /etc/bash.bashrc file.

alias gitl='git --git-dir=.gitlab'
alias gitp='git --git-dir=.gitproj'
Community
  • 1
  • 1
Martin F
  • 23
  • 3

1 Answers1

0

Usually when you run repository actions git performs a lookup for .git subdirectory of git process directory. So putting .git dir anywhere under class directory doesn't fit you case. But there's a way to tell git use custom .git directory anywhere on your file system my passing it's path via environment variable GIT_DIR.

So I would do this:

  1. Create a root repository of your project, lets name it root.
  2. Create two repositories like a root/Project and root/Lab and your sources root/class. So far there are root/Project/.git and root/Lab/.git but no any .git subdirectory could be found in root/class

  3. Make GIT_DIR=<path-to-root>/Project git add <file> for Project repository files. Then commit it GIT_DIR=<path-to-root>/Project git commit -m "Initialise Project repo"

  4. Make GIT_DIR=<path-to-root>/Lab git add <file> for Labs repository files and commit the same way.

You always have to provide correct GIT_DIR variable every time you call git. It's a bit tricky to remember which repo file belongs to but that's what you want :)

Sergei Voitovich
  • 2,804
  • 3
  • 25
  • 33
  • Thanks, I updated my post with the solution I came up with. It's fairly similar to yours with the exception of where the repositories are actually located. – Martin F Dec 02 '16 at 20:19