I'm trying to find ways to configure Git repository for a project on which two groups work.
Each of the two groups should have access authorities as follows.
- Group 1: accessible to both of '/src/dir_public' and '/src/dir_private'
- Group 2: accessible only to '/src/dir_public'
After googling to find out answers, I thought "git-submodule" might be one of the solutions at first.
But after a quick test, I found that it is not I really want.
I thought that submodules would not be tracked from so-called "superproject", but they were.
In other words, I'd like to merge changes in 'src/dir_public' which can be commited by both groups, but I don't want Group2 to know about "src/dir_private".
Would it be possible to configure Git repository as follows?
Directories visible on "master" branch (group1)
- src/dir_public (repo_public)
- src/dir_private (repo_private)
Directories visible on "private" branch (group1)
- src/dir_public (repo_public)
- src/dir_private (repo_private)
Directories visible on "public" branch (shared with group2)
- src/dir_public (repo_public)
I'd like to manage/sync-up codes in the following ways
- Merge "public" branch into "master" branch: any update on "public" branch should be merged into "master" branch
- Merge "private" branch into "master" branch: any update on "private" branch should be merged into "master" branch
- Merge "master" branch into "public" branch: This will work but I don't want dir_private to be visible on "public" branch.
Lastly, I'm adding what I tested.
$ mkdir ~/superproject
$ cd ~/superproject
$ git init
$ mkdir src; mkdir dir_public;
$ cd src/dir_public
$ echo public code > public.c
$ git add .
$ git commit -am "Added the public file."
[master (root-commit) 9b11e8c] Added the public file.
1 file changed, 1 insertion(+)
create mode 100644 src/dir_public/public.c
$ mkdir ~/dir_private
$ cd ~/dir_private
$ git init
$ echo private code > private.c
$ git add .
$ git commit -am "Added the private file."
[master (root-commit) 9d34bb2] Added the private file.
1 file changed, 1 insertion(+)
create mode 100644 dir_private/private.c
$ cd ~/superproject/src
$ git submodule add ~/dir_private/
Cloning into '~/superproject/src/dir_private'...
done.
$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: ../.gitmodules
new file: dir_private