{"thread":{"id":"24879","subject":"how to change permissions of git repo","startedAt":"2010-08-27T03:03:30Z","lastAt":"2010-08-27T03:03:30Z","messageCount":1,"participants":["Neal Kreitzinger"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"149101","messageId":"i57a0n$vm2$5@dough.gmane.org","threadId":"24879","inReplyTo":null,"subject":"how to change permissions of git repo","fromName":"Neal Kreitzinger","fromEmail":"neal@rsss.com","sentAt":"2010-08-27T03:03:30Z","receivedAt":"2010-08-27T03:03:30Z","isPatch":false,"sender":{"key":"neal@rsss.com","avatar":null},"body":"Here is the technique I devised to change permissions on a git repo.  I \nneeded to lock down a repo so only the integration manager has write access. \nThis method ensures that git sets the permissions according to gits rules. \nPlease let me know if you know of an easier/better way to do this.\n\nChange Permissions on an Existing Git Repo:\n\nCheck System for Users who may be using the Repo:\n# w  (see who's logged in)\n# ps -A |grep git-menu-scriptname  (where scriptname is some unique string \nin the name of the main script your users use to access that repo, if \napplicable)\n# skill -KILL pts/99  (where 99 = the pts/# from w command, log the user \noff)\n\nChange Shared=group to Shared=0644  (change group read+write to group read \nonly):\nCreate Template for permissions:\nlogin as fsngit0\n$ cd /path/to/template\n$ cat config\n[core]\n        sharedRepository = 0644\n\nClone repo to set permissions via git:\n$ cd /path/to/repo-parent-dir\n$ git clone --bare --template=/path/to/template file:///path/to/REPO.git \nREPOMOD.git\n\nCompare old and new versions:\n$ diff -r REPO.git REPOMOD.git\nOnly in REPO.git: branches  (empty, keep the old version)\ndiff -r REPO.git/config REPOMOD.git/config  (merge the old and new together)\n1a2\n>       sharedrepository = 0644\n6,7c7\n<         denyDeletes = true\n<         denyNonFastForwards = true\n---\n>       denyNonFastforwards = true\nOnly in REPO.git: description  (keep the old version)\nOnly in REPO.git: gitk.cache  (gitk will recreate this)\nOnly in REPO.git: hooks  (contains sample scripts only or whatever scripts \nyour using, keep the old version)\nOnly in REPO.git: info  (keep the old version: contains attributes, exclude, \nor whatever you've setup)\nOnly in REPO.git/objects: aa (keep new version, loose object have been \npacked)\nOnly in REPO.git/objects/pack: \npack-A5735e9b894dce1498ec1c776dcabc97fd8ceAfc.idx\ndiff -r REPO.git/packed-refs REPOMOD.git/packed-refs  (keep the new version \nbecause fresh clone has been optimized)\n2c2\n< Xa8b7b8c8fd3920b89770f2e8356f4ecb71a58cX refs/heads/master\n---\n> Ya69744e46276a37932d5f0755a53f76cdf83e0dY refs/heads/master\nOnly in REPO.git/refs/heads: master  (old version not needed because fresh \nclone has been optimized)\n\nCopy over REPO.git files that the clone didn't replicate, but that you need \nin order to retain all settings:\n$ cp -rv /path/to/REPO.git/info .\nrepeat as needed...\n\nchange permissions to g-w or whatever your core.sharedRepository new value \nis supposed to be:\n$ chmod -R g-w info\nrepeat as needed...\n\nValidate your changes:\n$ diff -r REPO.git REPOMOD.git\ndiff -r REPO.git/config REPOMOD.git/config\n1a2\n>       sharedrepository = 0644\n7c8\n<         denyNonFastForwards = true\n---\n>       denyNonFastforwards = true\nOnly in REPO.git: gitk.cache\nOnly in REPO.git/objects: aa\nOnly in REPO.git/objects/pack: \npack-A5735e9b894dce1498ec1c776dcabc97fd8ceAfc.idx\ndiff -r REPO.git/packed-refs REPOMOD.git/packed-refs\n2c2\n< Xa8b7b8c8fd3920b89770f2e8356f4ecb71a58cX refs/heads/master\n---\n> Y69744e46276a37932d5f0755a53f76cdf83e0dY refs/heads/master\nOnly in REPO.git/refs/heads: master\n\nBackup REPO.git and rename REPOMOD.git to REPO.git:\n$ cp -rvp REPO.git REPO.git-old\n$ diff -r REPO.git REPO.git-old\n$ rm -rf REPO.git\n$ cp -rvp REPOMOD.git REPO.git\n$ diff -r REPO.git REPOMOD.git\n$ diff -r REPO.git REPO.git-old\n\nv/r,\nNeal \n"}]}