{"thread":{"id":"17281","subject":"how to git a read only directory","startedAt":"2009-01-21T08:33:54Z","lastAt":"2009-01-22T12:35:13Z","messageCount":10,"participants":["bill lam","Michael J Gruber","Boaz Harrosh"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"101355","messageId":"20090121083354.GG6970@b2j","threadId":"17281","inReplyTo":null,"subject":"how to git a read only directory","fromName":"bill lam","fromEmail":"cbill.lam@gmail.com","sentAt":"2009-01-21T08:33:54Z","receivedAt":"2009-01-21T08:33:54Z","isPatch":false,"sender":{"key":"cbill.lam@gmail.com","avatar":null},"body":"I want to use git to keep track of files inside /etc but do not want\nto do it as a super user. Is that possible to put GIT_DIR under my\nhome directory and add public-read files inside /etc? Or that it could\nbe done in some other ways.\n\nThanks.\n\n-- \nregards,\n====================================================\nGPG key 1024D/4434BAB3 2008-08-24\ngpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3\n唐詩164 張喬  書邊事\n    調角斷清秋  征人倚戍樓  春風對青塚  白日落梁州\n    大漠無兵阻  窮邊有客遊  蕃情似此水  長願向南流\n"},{"id":"101363","messageId":"4976F195.9030908@drmicha.warpmail.net","threadId":"17281","inReplyTo":"20090121083354.GG6970@b2j","subject":"Re: how to git a read only directory","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-01-21T09:57:41Z","receivedAt":"2009-01-21T09:57:41Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"bill lam venit, vidit, dixit 21.01.2009 09:33:\n> I want to use git to keep track of files inside /etc but do not want\n> to do it as a super user. Is that possible to put GIT_DIR under my\n> home directory and add public-read files inside /etc? Or that it could\n> be done in some other ways.\n> \n> Thanks.\n> \n\nYou can use the core.worktree config variable in order to specify a\nworktree (/etc) which is not directly above .git. For your git commands\nto find the .git dir you would need to set GIT_DIR or use the --git-dir\nparameter.\n\nI have found, though, that several git commands require you to be within\nthe worktree or else they become confused. I use a shell function for\nthat, doing something like \"gg ~/path/project log\" which requires\n~/path/project.git to have its core.worktree set. Also, having a git\nalias like \"git view\" set up for gitk helps calling gitk in that way.\ngit-gui makes unfounded assumptions and is completely unhappy in a\nsituation like that.\n\nI think the situation around GIT_DIR and and worktree is a bit in the\nflux at the moment (panta rhei..) but it works for me.\n\nCheers,\nMichael\n\nHere's the \"git go\" bash function. I'm not proud of it, it makes several\nassumptions and does no error checking. Use it like \"gg path/project\ncommand parameters\" if the git-dir is \"path/project.git\" or \"gg\npath/project/\" if the git-dir is \"path/project/.git\". Have your\ncore.worktree set in the former case, and also in the latter if the\nworktree is not \"path/project\".\n\nI'm sure it can be done much better using helper functions from git's\nbash-completion, e.g.\n\ngg ()\n{\n    local _gg=\"$1\";\n    shift;\n    local _ggwt=`git --git-dir=\"${_gg}.git\" config --get core.worktree`;\n    if [ -z \"${_ggwt}\" ]; then\n        _ggwt=$(cd ${_gg} 2> /dev/null && pwd -P);\n    fi;\n    local _gggd=$(cd ${_gg}.git 2> /dev/null && pwd -P);\n    pushd ${_ggwt} > /dev/null;\n    git --git-dir=${_gggd} \"$@\";\n    popd > /dev/null\n}\n"},{"id":"101378","messageId":"4977164B.4020706@panasas.com","threadId":"17281","inReplyTo":"20090121083354.GG6970@b2j","subject":"Re: how to git a read only directory","fromName":"Boaz Harrosh","fromEmail":"bharrosh@panasas.com","sentAt":"2009-01-21T12:34:19Z","receivedAt":"2009-01-21T12:34:19Z","isPatch":false,"sender":{"key":"bharrosh@panasas.com","avatar":"https://gravatar.com/avatar/347e426f8ca0409f6891ceeefd4c3c2d8769608382323057efeaa362b4c3dbf3?d=mp&s=160"},"body":"bill lam wrote:\n> I want to use git to keep track of files inside /etc but do not want\n> to do it as a super user. Is that possible to put GIT_DIR under my\n> home directory and add public-read files inside /etc? Or that it could\n> be done in some other ways.\n> \n> Thanks.\n> \nI did the really easy hack (on my /etc BTW) and it worked fine for me.\n\nI created a master project folder under ~home, init a new git repo,\nthen symlink /etc/ onto an etc/ in the project dir, added all etc/\nfiles. I like the extra a/etc/fstab in the patch files better then\na/fstab.\n\nAnd it is a life saver, payed it's effortless in gold. Some shining\nnew distro should come up with a git based management system\nand it will leave all the other distros in the dust.\n\nCheers\nBoaz\n"},{"id":"101396","messageId":"20090121154842.GA6966@b2j","threadId":"17281","inReplyTo":"4976F195.9030908@drmicha.warpmail.net","subject":"Re: how to git a read only directory","fromName":"bill lam","fromEmail":"cbill.lam@gmail.com","sentAt":"2009-01-21T15:48:42Z","receivedAt":"2009-01-21T15:48:42Z","isPatch":false,"sender":{"key":"cbill.lam@gmail.com","avatar":null},"body":"On Wed, 21 Jan 2009, Michael J Gruber wrote:\n> You can use the core.worktree config variable in order to specify a\n> worktree (/etc) which is not directly above .git. For your git commands\n> to find the .git dir you would need to set GIT_DIR or use the --git-dir\n> parameter.\n\nMichael, thanks for pointing out worktree being the trick to use.\n\n-- \nregards,\n====================================================\nGPG key 1024D/4434BAB3 2008-08-24\ngpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3\n唐詩267 王翰  涼州詞\n    葡萄美酒夜光杯  欲飲琵琶馬上催  醉臥沙場君莫笑  古來征戰幾人回\n"},{"id":"101397","messageId":"20090121155256.GB6966@b2j","threadId":"17281","inReplyTo":"4977164B.4020706@panasas.com","subject":"Re: how to git a read only directory","fromName":"bill lam","fromEmail":"cbill.lam@gmail.com","sentAt":"2009-01-21T15:52:56Z","receivedAt":"2009-01-21T15:52:56Z","isPatch":false,"sender":{"key":"cbill.lam@gmail.com","avatar":null},"body":"On Wed, 21 Jan 2009, Boaz Harrosh wrote:\n> I created a master project folder under ~home, init a new git repo,\n> then symlink /etc/ onto an etc/ in the project dir, added all etc/\n> files. I like the extra a/etc/fstab in the patch files better then\n> a/fstab.\n\nI create a symlink in ~/gitrepo/etc to /etc and git init an empty repo\nthere. However it failed in symlink when I tried to add files.  Could\nyou give more detail how to do it?  Meanwhile I use worktree method as\nsuggested by Michael.\n\n-- \nregards,\n====================================================\nGPG key 1024D/4434BAB3 2008-08-24\ngpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3\n唐詩205 元稹  遣悲懷三首之一\n    謝公最小偏憐女  自嫁黔婁百事乖  顧我無衣搜藎篋  泥他沽酒拔金釵\n    野蔬充膳甘長藿  落葉添薪仰古槐  今日俸錢過十萬  與君營奠復營齋\n"},{"id":"101404","messageId":"4977515B.9030807@panasas.com","threadId":"17281","inReplyTo":"20090121155256.GB6966@b2j","subject":"Re: how to git a read only directory","fromName":"Boaz Harrosh","fromEmail":"bharrosh@panasas.com","sentAt":"2009-01-21T16:46:19Z","receivedAt":"2009-01-21T16:46:19Z","isPatch":false,"sender":{"key":"bharrosh@panasas.com","avatar":"https://gravatar.com/avatar/347e426f8ca0409f6891ceeefd4c3c2d8769608382323057efeaa362b4c3dbf3?d=mp&s=160"},"body":"bill lam wrote:\n> On Wed, 21 Jan 2009, Boaz Harrosh wrote:\n>> I created a master project folder under ~home, init a new git repo,\n>> then symlink /etc/ onto an etc/ in the project dir, added all etc/\n>> files. I like the extra a/etc/fstab in the patch files better then\n>> a/fstab.\n> \n> I create a symlink in ~/gitrepo/etc to /etc and git init an empty repo\n> there. However it failed in symlink when I tried to add files.  Could\n> you give more detail how to do it?  Meanwhile I use worktree method as\n> suggested by Michael.\n> \n\nWhat? I don't know this is what I did:\n\n[~] $ mkdir gitrepo; cd gitrepo\n[gitrepo] $ git-init\n[gitrepo] $ ln -s /etc\n[gitrepo] $ git-add /etc/fstab\n[gitrepo] $ git-commit -s\n  Edit commit message in editor\n[gitrepo] $ git-show\ncommit fd6a4a72bf91526b56528f4036c525f6d6fd3dc0\nAuthor: Boaz Harrosh <bharrosh@panasas.com>\nDate:   Wed Jan 21 18:36:58 2009 +0200\n\n    {REMOVEME} etc/fstab test\n\n    Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>\n\ndiff --git a/etc/fstab b/etc/fstab\nnew file mode 100644\nindex 0000000..2e3f8d3\n--- /dev/null\n+++ b/etc/fstab\n@@ -0,0 +1,18 @@\n+LABEL=/fc7              /                       ext3    noatime         1 1\n+LABEL=/usr0             /usr0                   ext3    noatime         1 2\n+LABEL=/boot             /boot                   ext2    noatime         1 2\n+LABEL=/fc10             /alt                    ext3    defaults        1 2\n+tmpfs                   /dev/shm                tmpfs   defaults        0 0\n+devpts                  /dev/pts                devpts  gid=5,mode=620  0 0\n+sysfs                   /sys                    sysfs   defaults        0 0\n+proc                    /proc                   proc    defaults        0 0\n+LABEL=SWAP-sda7         swap                    swap    defaults        0 0\n+panstor:/main          /mnt/panstor            nfs     soft,intr,rsize=65536,wsize=65536 0 0\n  <... snip ...>\n\nSo in short I did nothing. I have git 1.6.0.1\n\nBoaz\n"},{"id":"101515","messageId":"20090122100008.GC6936@b2j","threadId":"17281","inReplyTo":"4977515B.9030807@panasas.com","subject":"Re: how to git a read only directory","fromName":"bill lam","fromEmail":"cbill.lam@gmail.com","sentAt":"2009-01-22T10:00:08Z","receivedAt":"2009-01-22T10:00:08Z","isPatch":false,"sender":{"key":"cbill.lam@gmail.com","avatar":null},"body":"On Wed, 21 Jan 2009, Boaz Harrosh wrote:\n> [~] $ mkdir gitrepo; cd gitrepo\n> [gitrepo] $ git-init\n> [gitrepo] $ ln -s /etc\n> [gitrepo] $ git-add /etc/fstab\n\n(I use git ver. 1.6.1, git-xxx is already deprecated)\nI followed your example, and failed in the git add,\n\ngitrepo$  git add /etc/fstab\nfatal: '/etc/fstab' is outside repository\n\n-- \nregards,\n====================================================\nGPG key 1024D/4434BAB3 2008-08-24\ngpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3\n唐詩260 李益  江南曲\n    嫁得瞿塘賈  朝朝誤妾期  早知潮有信  嫁與弄潮兒\n"},{"id":"101518","messageId":"4978483D.6040105@panasas.com","threadId":"17281","inReplyTo":"20090122100008.GC6936@b2j","subject":"Re: how to git a read only directory","fromName":"Boaz Harrosh","fromEmail":"bharrosh@panasas.com","sentAt":"2009-01-22T10:19:41Z","receivedAt":"2009-01-22T10:19:41Z","isPatch":false,"sender":{"key":"bharrosh@panasas.com","avatar":"https://gravatar.com/avatar/347e426f8ca0409f6891ceeefd4c3c2d8769608382323057efeaa362b4c3dbf3?d=mp&s=160"},"body":"bill lam wrote:\n> On Wed, 21 Jan 2009, Boaz Harrosh wrote:\n>> [~] $ mkdir gitrepo; cd gitrepo\n>> [gitrepo] $ git-init\n>> [gitrepo] $ ln -s /etc\n>> [gitrepo] $ git-add /etc/fstab\n> \n\nSorry My mistake, it should be:\n[gitrepo] $ git-add etc/fstab\n\n> (I use git ver. 1.6.1, git-xxx is already deprecated)\n> I followed your example, and failed in the git add,\n> \n> gitrepo$  git add /etc/fstab\n> fatal: '/etc/fstab' is outside repository\n> \n\nSorry it's a typo, sure you must add files relative to\nthe base directory (one containing the .git/ dir)\n\nCheers\nBoaz\n"},{"id":"101519","messageId":"20090122102925.GD6936@b2j","threadId":"17281","inReplyTo":"4978483D.6040105@panasas.com","subject":"Re: how to git a read only directory","fromName":"bill lam","fromEmail":"cbill.lam@gmail.com","sentAt":"2009-01-22T10:29:25Z","receivedAt":"2009-01-22T10:29:25Z","isPatch":false,"sender":{"key":"cbill.lam@gmail.com","avatar":null},"body":"On Thu, 22 Jan 2009, Boaz Harrosh wrote:\n> Sorry My mistake, it should be:\n> [gitrepo] $ git-add etc/fstab\n> \n> Sorry it's a typo, sure you must add files relative to\n> the base directory (one containing the .git/ dir)\n\nHi Boaz,\n\nI still could not add the file. This time it said symbolic link error.\n\ngitrepo$ ll -A\ntotal 4\nlrwxrwxrwx 1 bill bill    4 2009-01-22 17:54 etc -> /etc\ndrwxr-xr-x 7 bill bill 4096 2009-01-22 18:23 .git\ngitrepo$ pwd\n/home/bill/gitrepo\ngitrepo$ git add etc/fstab\nfatal: 'etc/fstab' is beyond a symbolic link\n\n-- \nregards,\n====================================================\nGPG key 1024D/4434BAB3 2008-08-24\ngpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3\n唐詩314 王昌齡  長信怨\n    奉帚平明金殿開  且將團扇共徘徊  玉顏不及寒鴉色  猶帶昭陽日影來\n"},{"id":"101523","messageId":"49786801.4010606@panasas.com","threadId":"17281","inReplyTo":"20090122102925.GD6936@b2j","subject":"Re: how to git a read only directory","fromName":"Boaz Harrosh","fromEmail":"bharrosh@panasas.com","sentAt":"2009-01-22T12:35:13Z","receivedAt":"2009-01-22T12:35:13Z","isPatch":false,"sender":{"key":"bharrosh@panasas.com","avatar":"https://gravatar.com/avatar/347e426f8ca0409f6891ceeefd4c3c2d8769608382323057efeaa362b4c3dbf3?d=mp&s=160"},"body":"bill lam wrote:\n> On Thu, 22 Jan 2009, Boaz Harrosh wrote:\n>> Sorry My mistake, it should be:\n>> [gitrepo] $ git-add etc/fstab\n>>\n>> Sorry it's a typo, sure you must add files relative to\n>> the base directory (one containing the .git/ dir)\n> \n> Hi Boaz,\n> \n> I still could not add the file. This time it said symbolic link error.\n> \n\nOK so it looks like it is something new. Good to know I will not\nupgrade for now as I do use it a lot. Unless there is some config\nnub that can be turned. I must say that it is most useful, I use\nit everyday.\n\nSomeone please comment why are symlink not allowed. Is that because\nit might be dangerous? but so is a gun I might shoot myself in the\nleg, but they are still been sold.\n\nBoaz\n"}]}