Reputation: 377
Does git support a concept of a sub branch; ie a branch of a branch
For example a group of teachers have a bare shared repo on a network drive (no server ssh authentication etc) that they pull and push to on a shared drive merging into master when appropriate.
This repo would include teacher files such as worked solutions as well as student files.
Students shouldn't clone this repo nor checkout their respective teachers branch directly as it contains the answers.
But the repo could contain a branch for each class/topic with only student files that tracks upstream changes. Students then branch this branch to do their work. Teacher tracks the student branch as a remote and pulls in the work.
The closest I have come to the above is cloning a single branch into a separate repo and having students branch in that repo. The problems with the above include obvious data duplication (windows support of system-links within git is poor) and extra class/topic repos that have to be kept updated with upstream changes.
Any ideas how to better support this workflow in Git/LibGit2 ?
Upvotes: 2
Views: 13142
Reputation: 16587
I use a similar flow, but with two distinct histories (i.e. two different repositories that do not have any commit in common): one for teachers, and one for students. Having two separate histories has several advantages:
I can include generated files (e.g. *.pdf) in the student's repository, and track source files (e.g. *.tex) in the teacher's one.
I do not need to show individual commits made by teachers on the student's repository. They just see ~1 commit per class saying "new class online".
I chose which file I want to publish.
In my teacher's repository, I have a makefile with an make install
target that copies the generated files to the student's repository. For convenience, I have targets make git-commit
, make git-push
that run git commit
and git push
in the student's checkout.
On the students side, they run git clone
once, git pull
whenever I add new stuff. The can use my repository as a skeleton for their lab works, and work collaboratively (I advise them to use one remote for their coworker and one remote for me).
Upvotes: 1
Reputation: 1328172
Does git support a concept of a sub branch; ie a branch of a branch
No, a branch can be renamed, deleted or rebased (ie moved around) at any time.
It does support the notion of "namespace" (or hierarchy, or group), with the name of the branch including one or several "/
": class/topic
can be the name of a branch.
You find a similar use of namespace with gitolite (an ACL to control access to Git repos based on authentication).
See:
Upvotes: 2
Reputation: 175048
There's no notion of a main branch in git (master
is a completely normal branch that git provides by default). You can branch off of master
, you can branch off of any other branch, you can branch off of a branch of a branch of a branch of a branch.
To your specific questions, git doesn't have a concept of branch visibility. If I clone your repo, I get all of the branches just fine, and it doesn't matter how your local repo tracks the remote branches.
In short, if you don't want people having information that's available to the repo, don't allow them to clone it. Provide a different remote repo with just the information you need, and push only the relevant information there.
So for example, my repo has branches public
, private-1
and private-2
, I can push all of my branches to origin
(git push private-remote private-1
etc), and have another remote setup where you strictly only push public
to it.
Your students then clone the public remote, branch off of public
, push their changes and their own branches, then you can pull those branches from public-remote
and push into your private-remote
. Git supports multiple remotes just fine.
Upvotes: 4