0

In a single directory with a Git root folder, I have a bunch of files. I am working on one of those files, X.py, with my friend Alice. The other files I am working on with other people. I want Alice (and everyone else) to have access to X.py. I want Alice to only have access to X.py though.

How can I achieve this with Git? Is there a way I can split a directory into two repos? That sounds rather cumbersome. Maybe I could add a remote repo that Alice can access containing X.py?

2
  • 3
    Don't share the repository. Instead, have Alice send you updates / patches as needed.
    – parsifal
    Mar 26, 2013 at 21:08
  • @parsifal You should add that as an answer
    – remmy
    Mar 31, 2013 at 15:36

2 Answers 2

1

If it was SVN you could easily handle this with permissions, but most DCVSes don't have that fine-grained permissions as that is completely unworkable with everyone having a copy of the repository.

Probably the best way to handle this would be to have alice fork the repository and submit pull requests -- you could then make sure she is just working in X.py and not anything else.

If you don't want her reading anything else then you'd need to work with subrepos. But as a great man once said "when you've got a problem and you say 'hey, I'll use subrepositories' then you've got two problems."

0

You make a branch X and delete everything except X.py and the push the branch to a central repository. If you want to share Y.py also, you add it to your branch and you merge this branch with X from the central repository.

You don't push to the central repository anything that you don't want to be seen by others.

1
  • 1
    Unfortunately, if you want the remote branch to be mergeable, it must contain all the history from before you deleted the other files. Mar 26, 2013 at 23:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.