I'll-Be-Back
I'll-Be-Back

Reputation: 10828

How to restrict folders / files on a Git repo?

On Github, how do I restrict some folders or files on a private repo?

I do not want to give developers full access to everything in a repo.

Upvotes: 5

Views: 5519

Answers (1)

blue112
blue112

Reputation: 56432

You can't.

If you give someone the push permission, he will be able to push whatever he want.

If you want someone to have a partial access, you have many choices:

  • Make him fork and pull-request the repository. You can check whether it fullfill your purpose
  • Make very clear that he should not modify any other files/folders that theses one, and check in commit history from time to time.
  • Make a post-receive hook that check what the commit modifies, the author and reject or accept the commit based on that.

If you don't want him to have read access on other files, then the best way to go is to create a separate git repository for him, and use it as a submodule of your own git repository. See here: https://git-scm.com/book/en/v2/Git-Tools-Submodules

Upvotes: 2

Related Questions