Git clone with different file permissions

On our server, there are three (in fact: thousands) text files stored in the bare git repository: A.txt, B.txt, C.txt.

  • The user "admin" must view / edit everything.
  • User "Foo" must view / edit "A.txt" and "B.txt", but he is not allowed to see the contents of "C.txt".
  • The user "guest" must allow viewing / editing of "A.txt".

All three users should be able to clone the git repository with the files that they are allowed to edit.

Is there any way to do this with git (... or mercurial)?

Idea: can I make two clones of the bare git repository with sparse check the git function for the user "Foo" and "guest", which includes only the files that they are allowed to see?

Any other (faster) idea?

+3
source share
1 answer

You should:

  • have three branches
    • guest (with A.txtfiles only )
    • users (with files A and B.txt)
    • admin (with all files)

This means frequent merges to update different branches and propagate various changes.

In addition, with gitolite you can control who can pull / push what (at the branch level), which means:

  • guest.
  • foo guest users, users ( , , guest).
  • / .
+2

Source: https://habr.com/ru/post/1760328/


All Articles