{"thread":{"id":"19782","subject":"sub-directory repo technique","startedAt":"2009-06-12T12:07:20Z","lastAt":"2009-06-16T16:50:49Z","messageCount":2,"participants":["Allan Kelly","Avery Pennarun"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"116143","messageId":"9586f3420906120507o194fc459l5fbdcd14a7095ae8@mail.gmail.com","threadId":"19782","inReplyTo":null,"subject":"sub-directory repo technique","fromName":"Allan Kelly","fromEmail":"allankelly@gmail.com","sentAt":"2009-06-12T12:07:20Z","receivedAt":"2009-06-12T12:07:20Z","isPatch":false,"sender":{"key":"allankelly@gmail.com","avatar":"https://gravatar.com/avatar/c62021c01204c1e0c91084a96d4c16f19d394d3e67f6f51c707686da1d59cb64?d=mp&s=160"},"body":"Hi,\n\nI'm quite new to git, but it is serving me well.  The main scenario I\nam working with is my own code bases with several centralised repos on\na server. I clone, develop and push from a various machines, rather\nthan working on the server. Great!\n\nHowever, for one of my projects I have the following:\n\n* xidebar repo contains perl programs & modules, and a projects/ directory\n* Under projects/ are self-contained project trees, eg\nprojects/westbarnsgala.info\n* The total size is quite large and it's undesirable to clone the\nwhole thing remotely\n* I want to be able to remote clone, edit, and push just a specific\nprojects/westbarnsgala.info tree\n\nI have a solution which works fine for me below. I wonder if this is\nrecommended however, or whether there's \"another way to do it\"?\nProbably!\n\nWith xidebar as the 'parent' repo on the \"rss_rand\" server for\ntracking all xidebar contant together, I then go into the individual\nproject/proj1 dirs and create a repo there. I can then remotely clone\nthis repo, edit and push as below.\n\nHere's the blow-by-blow description.\n\n(I need the top-level .gitignore to contain a line '.gitignore' to\navoid reporting the \"sub-repo\" .gitignore as untracked - which is\ncorrect but not of interest. It appears that git automatically ignores\nthe .git dir for the westbarnsgala.info repo created below)\n\nOn rss_rand server:\nWith previously created xidebar/ repo:\n* add line '.gitignore' in xidebar/.gitignore\n1. Create westbarnsgala.info repo\n* cd projects/westbarnsgala.info\n* git init\n* git add .\n* git commit -a -m 'initial commit'\n2. On other machine: Clone, edit, commit locally and push changes remotely\n* cd projects\n* git clone rss_rand:~/xidebar/projects/westbarnsgala.info/ wbg\n* cd wbg\n* vi htmlgen.xml\n* commit -a -m 'a smalll update'\n* git push origin\n3. On rss_rand: Update local files with remote changes from local repo\n* => The git repo is up to date with the remote edit.\n* => The files are not.\n* => A checkout reports the mis-match and bails.\n* => So force it.\n* git checkout -f\n* => Now the files are up to date!\nNow 'git status' on either machine shows things are up to date.\n4. Now, back to the rss_rand xidebar repo: commit changes.\n* cd ../..\n* git status => Shows changes detected correctly\n* git commit -a -m 'update to westbarnsgala.info'\n\nRoutine of work is now:\nEdit on laptop.\n* => If in doubt, start with a 'git pull' (Which does both fetch and merge).\n* commit -a -m 'a message'\n* git push\nPublish from rss_rand (overnight cron script):\n* cd xidebar/projects/westbarnsgala.info\n* git status => Just to check\n* git checkout -f\n* cd ../..\n* ./xidebar westbarnsgala.info && ftp_dir_diff westbarnsgala.info\n\n\nCheers, al.\n"},{"id":"116417","messageId":"32541b130906160950s75f4aa11h59ad2de7d2bcd40c@mail.gmail.com","threadId":"19782","inReplyTo":"9586f3420906120507o194fc459l5fbdcd14a7095ae8@mail.gmail.com","subject":"Re: sub-directory repo technique","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2009-06-16T16:50:49Z","receivedAt":"2009-06-16T16:50:49Z","isPatch":false,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"On Fri, Jun 12, 2009 at 8:07 AM, Allan Kelly<allankelly@gmail.com> wrote:\n> (I need the top-level .gitignore to contain a line '.gitignore' to\n> avoid reporting the \"sub-repo\" .gitignore as untracked - which is\n> correct but not of interest. It appears that git automatically ignores\n> the .git dir for the westbarnsgala.info repo created below)\n\nIt's not really \"ignoring\" the .git dir.  It's treating the entire\nsubtree that contains the .git dir as a submodule.  See 'man\ngit-submodule'.  Git submodules may actually resolve your problem in a\nmore straightforward way than what you're doing.\n\nYou might also be interested in my git-subtree tool:\nhttp://github.com/apenwarr/git-subtree\n\nHave fun,\n\nAvery\n"}]}