4

We're getting a freelancer to work on parts of our webapp - and I'd like to restrict his access to just the front end parts of the our code repo - is there a way to do this in Git? We're using bitbucket to host the repo. We have a lot of unique propreitary backend code that we dont want him to see and he doesnt need to see in order to do his job.

CharlesB
  • 86,532
  • 28
  • 194
  • 218
user1198133
  • 169
  • 1
  • 1
  • 7
  • Is it all in one repository? Because if yes, then [you probably can't](http://stackoverflow.com/questions/8047416/gitolite-or-gitosis-permission-on-directory-inside-of-the-repository). – Roman Aug 02 '12 at 05:06

2 Answers2

4

you can make a new branch by using filter branch to only include history of the paths that contain files for him only. Push this branch to another repo. Give him rights to that repo. Pull his changes from that repo. Merge that branch in your original repos to incorporate his work with the rest of the code.

Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141
1

Alternatively, if you had your repository not at bitbucket but at the server you can control, you could install SubGit into the Git repository (it will create a linked SVN repository for it) and then setup paths-based authentication in the resulting SVN repository and give the freelancer SVN URL.

But you may still do that with a clone of your repository.

$ svnadmin create svn.repo
$ git clone --mirror GIT_URL svn.repo/.git
$ subgit install svn.repo

And setup access to svn.repo (something like this):

LoadModule dav_svn_module "/usr/lib/apache2/modules/mod_dav_svn.so"
LoadModule authz_svn_module "/usr/lib/apache2/modules/mod_authz_svn.so"
<Location /repos>                                                                                                                                                                                       
DAV svn                                                                                                                                                                                               
SVNPath "/path/to/svn.repo"                                                                                                     
AuthzSVNAccessFile "path/to/authz"                                                                                                              
Allow from any                                                                                                                                                                                        
AuthType Basic                                                                                                                                                                                        
AuthName "Subversion Repository"                                                                                                                                                                           
AuthUserFile /path/to/htpasswdfile                                                                                                                    
Require valid-user                                                                                           
</Location>

And path/to/authz (something like this):

[/]                                                                                                  
*=
[/some/dir]
freelancer=rw

And git SVN URL to the freelancer. After all, you may need just push a branch of "svn.repo/.git" repository to GIT_URL back.

$ cd svn.repo/.git
$ git push origin freelancer_branch
Dmitry Pavlenko
  • 8,530
  • 3
  • 30
  • 38