Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protecting files in git repository

I have a central repository with a subset of files that I want to protect from being changed (by pushing) from other users. If I add these files to .gitignore, they would not be cloned.

Is it possible to give the ability to clone all files, but after cloning add some of them to .gitignore on the client side?

like image 230
andrexus Avatar asked Jul 29 '10 06:07

andrexus


2 Answers

You can have the files in the repository, commit them, then add them to the .gitignore and then remove them from the next commit.

You can still fetch the files directly prior commit (perhaps tag it with something so it can be fetched by name a bit easier) and this will preserve the state of the file, while not making it easily edited in the repository by accident.

To access those files after pulling the clone, just write a rake task that fetches them for the user of your repository.

like image 122
vgoff Avatar answered Oct 04 '22 10:10

vgoff


It sounds to me like the problem lies elsewhere if you need this level of access restriction.

Nonetheless, if you indeed do want to implement this, consider Gitolite. It allows you to define rather detailed access rules and should probably suffice for your needs.

Gitolite documentation: http://gitolite.com/gitolite/master-toc.html

You can define 'virtual refs' to control access on file level. More on that: http://gitolite.com/gitolite/vref.html

like image 31
jsageryd Avatar answered Oct 04 '22 11:10

jsageryd