{"thread":{"id":"37952","subject":"how to reduce disk usage for large .git dirs?","startedAt":"2014-11-13T11:14:44Z","lastAt":"2014-11-25T14:32:59Z","messageCount":18,"participants":["Olaf Hering","Fredrik Gustafsson","Duy Nguyen","Roger Gammans","Johan Herland","Jeff King","Jakub Narębski","Andreas Schwab"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"251804","messageId":"20141113111444.GA15503@aepfle.de","threadId":"37952","inReplyTo":null,"subject":"how to reduce disk usage for large .git dirs?","fromName":"Olaf Hering","fromEmail":"olaf@aepfle.de","sentAt":"2014-11-13T11:14:44Z","receivedAt":"2014-11-13T11:14:44Z","isPatch":false,"sender":{"key":"olaf@aepfle.de","avatar":"https://avatars.githubusercontent.com/u/942324?v=4"},"body":"\nHow can I reduce the disk usage for multiple copies of the same repo?\n\nUp to now I just made copies like this, but since .git alone is already\n2GB it becomes expensive:\n\n # git clone git://host/repo.git repo-master\n # cp -a repo-master repo-branchA\n # cd repo-branchA\n # git checkout -b branchA origin/branchA\n # cd -\n # cp -a repo-master repo-branchB\n # cd repo-branchB\n # git checkout -b branchB origin/branchB\n # cd -\n # cp -a repo-master repo-branchB-feature\n # cd repo-branchB-feature\n # git checkout -b branchB-feature origin/branchB\n # cd -\n\n\nSince each .git is almost identical I wonder if there is a reliable way\nto \"share\" it. The \"git clone\" man page mentions --shared as a dangerous\nway to do things. It does not give an advice how to manage such cloned\ntrees.\n\nSo how can I reduce the disk usage needed for the four .git dirs above?\nI looked around in the docs that came with my git-2.1.3 package, but\nfound nothing that answers my question. Maybe we can workout something\nand add it to one of the existing docs.\n\nThanks!\n\nOlaf\n"},{"id":"251808","messageId":"20141113114919.GA2737@paksenarrion.iveqy.com","threadId":"37952","inReplyTo":"20141113111444.GA15503@aepfle.de","subject":"Re: how to reduce disk usage for large .git dirs?","fromName":"Fredrik Gustafsson","fromEmail":"iveqy@iveqy.com","sentAt":"2014-11-13T11:49:19Z","receivedAt":"2014-11-13T11:49:19Z","isPatch":false,"sender":{"key":"iveqy@iveqy.com","avatar":"https://avatars.githubusercontent.com/u/761743?v=4"},"body":"On Thu, Nov 13, 2014 at 12:14:44PM +0100, Olaf Hering wrote:\n> \n> How can I reduce the disk usage for multiple copies of the same repo?\n\nYou can use --local och --shared. As you say --shared can be dangerous.\nIf you don't understand the man page enough to know how you should\nmanage your clones you should probably not use it.\n\n--local seems to be what you're looking for.\n\nHowever as a side note I'm curious about what your use case is. Why do\nyou need this many repos?\n\nYour setup looks familiar to me for a subversion user switching to git\nand trying to use git as subversion. The common usecase is not to have\nmultiple worktrees but to do a checkout to the worktree you need to work\non. This is possible with git since it's very fast and I recommend you\nto try to use one worktree.\n\n-- \nMed vänlig hälsning\nFredrik Gustafsson\n\ntel: 0733-608274\ne-post: iveqy@iveqy.com\n"},{"id":"251813","messageId":"1415880149.4825.43.camel@knuth.computer-surgery.co.uk","threadId":"37952","inReplyTo":"20141113111444.GA15503@aepfle.de","subject":"Re: how to reduce disk usage for large .git dirs?","fromName":"Roger Gammans","fromEmail":"roger@gammascience.co.uk","sentAt":"2014-11-13T12:02:29Z","receivedAt":"2014-11-13T12:02:29Z","isPatch":false,"sender":{"key":"roger@gammascience.co.uk","avatar":null},"body":"On Thu, 2014-11-13 at 12:14 +0100, Olaf Hering wrote:\n> How can I reduce the disk usage for multiple copies of the same repo?\n> \n> Up to now I just made copies like this, but since .git alone is already\n> 2GB it becomes expensive:\n> \n>  # git clone git://host/repo.git repo-master\n>  # cp -a repo-master repo-branchA\n>  # cd repo-branchA\n>  # git checkout -b branchA origin/branchA\n>  # cd -\n>  # cp -a repo-master repo-branchB\n>  # cd repo-branchB\n>  # git checkout -b branchB origin/branchB\n>  # cd -\n>  # cp -a repo-master repo-branchB-feature\n>  # cd repo-branchB-feature\n>  # git checkout -b branchB-feature origin/branchB\n>  # cd -\n> \n> \n> Since each .git is almost identical I wonder if there is a reliable way\n> to \"share\" it. The \"git clone\" man page mentions --shared as a dangerous\n> way to do things. It does not give an advice how to manage such cloned\n> trees.\n\nBut you're not using clone you are using cp .\n\nThe clone man page also says this:-\n      --local, -l\n           When the repository to clone from is on a local machine, this flag bypasses the normal \"Git aware\" transport\n           mechanism and clones the repository by making a copy of HEAD and everything under objects and refs directories. The\n           files under .git/objects/ directory are hardlinked to save space when possible.\n\n           If the repository is specified as a local path (e.g., /path/to/repo), this is the default, and --local is essentially\n           a no-op. If the repository is specified as a URL, then this flag is ignored (and we never use the local\n           optimizations). Specifying --no-local will override the default when /path/to/repo is given, using the regular Git\n           transport instead.\n\n\nNote the first sentence of the second paragraph.\n eg:\n # git clone git://host/repo.git repo-master\n # git clone repo-master repo-branchA\n # cd repo-branchA\n # git checkout -b branchA origin/branchA\n # cd -\n # git clone repo-master repo-branchB\n # cd repo-branchB\n # git checkout -b branchB origin/branchB\n # cd -\n # git clone repo-master repo-branchB-feature\n # cd repo-branchB-feature\n # git checkout -b branchB-feature origin/branchB\n # cd -\n\nShould work better for you. And there is probably a way to do it less\ncommands too.\n\n-- \nRoger Gammans <roger@gammascience.co.uk>\n"},{"id":"251809","messageId":"20141113120313.GB15503@aepfle.de","threadId":"37952","inReplyTo":"20141113114919.GA2737@paksenarrion.iveqy.com","subject":"Re: how to reduce disk usage for large .git dirs?","fromName":"Olaf Hering","fromEmail":"olaf@aepfle.de","sentAt":"2014-11-13T12:03:13Z","receivedAt":"2014-11-13T12:03:13Z","isPatch":false,"sender":{"key":"olaf@aepfle.de","avatar":"https://avatars.githubusercontent.com/u/942324?v=4"},"body":"On Thu, Nov 13, Fredrik Gustafsson wrote:\n\n> On Thu, Nov 13, 2014 at 12:14:44PM +0100, Olaf Hering wrote:\n> > \n> > How can I reduce the disk usage for multiple copies of the same repo?\n> \n> You can use --local och --shared. As you say --shared can be dangerous.\n> If you don't understand the man page enough to know how you should\n> manage your clones you should probably not use it.\n\nPerhaps its more a lack of doc how to use the result.\n\n> --local seems to be what you're looking for.\n\nI will try this.\n\n> However as a side note I'm curious about what your use case is. Why do\n> you need this many repos?\n\nBecause I do work in each copy, poke around, or do commits and push\nthem.\n\n> Your setup looks familiar to me for a subversion user switching to git\n> and trying to use git as subversion. The common usecase is not to have\n> multiple worktrees but to do a checkout to the worktree you need to work\n> on. This is possible with git since it's very fast and I recommend you\n> to try to use one worktree.\n\nSwitching branches will invalidate timestamps, causing a full rebuild.\n\nOlaf\n"},{"id":"251810","messageId":"CACsJy8BytRtHkq1eXdEXMgjnZuDSOJs33nyQ1=xd4jtSDaZ8BA@mail.gmail.com","threadId":"37952","inReplyTo":"20141113111444.GA15503@aepfle.de","subject":"Re: how to reduce disk usage for large .git dirs?","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2014-11-13T12:09:58Z","receivedAt":"2014-11-13T12:09:58Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Thu, Nov 13, 2014 at 6:14 PM, Olaf Hering <olaf@aepfle.de> wrote:\n> Since each .git is almost identical I wonder if there is a reliable way\n> to \"share\" it. The \"git clone\" man page mentions --shared as a dangerous\n> way to do things. It does not give an advice how to manage such cloned\n> trees.\n\nIf you know what you are doing, you can try git-new-workdir in\ncontrib/workdir. A safe and reliable version of that is being worked\non, hopefully it'll be released in 2.3.0.\n-- \nDuy\n"},{"id":"251811","messageId":"20141113122119.GC15503@aepfle.de","threadId":"37952","inReplyTo":"1415880149.4825.43.camel@knuth.computer-surgery.co.uk","subject":"Re: how to reduce disk usage for large .git dirs?","fromName":"Olaf Hering","fromEmail":"olaf@aepfle.de","sentAt":"2014-11-13T12:21:20Z","receivedAt":"2014-11-13T12:21:20Z","isPatch":false,"sender":{"key":"olaf@aepfle.de","avatar":"https://avatars.githubusercontent.com/u/942324?v=4"},"body":"On Thu, Nov 13, Roger Gammans wrote:\n\n> Note the first sentence of the second paragraph.\n>  eg:\n>  # git clone git://host/repo.git repo-master\n>  # git clone repo-master repo-branchA\n>  # cd repo-branchA\n>  # git checkout -b branchA origin/branchA\n\nIt fails right here because in this dir only \"master\" exists, but\nbranchA is expected.\n\nSo far the sequence of commands is:\n\n# git clone git://host/repo.git repo-master\n# cd repo-master\n# git checkout -b branchA origin/branchA\n# git checkout -b branchB origin/branchB\n# cd -\n# git clone -l -b branchA repo-master repo-branchA\n# git clone -l -b branchB repo-master repo-branchB\n\nNext step will be:\n# $do_work ; git commit -avs ; git push \n\nWill that work as expected? Will find out after lunch..\n\n\nOlaf\n"},{"id":"251819","messageId":"20141113154457.GA31624@aepfle.de","threadId":"37952","inReplyTo":"20141113111444.GA15503@aepfle.de","subject":"Re: how to reduce disk usage for large .git dirs?","fromName":"Olaf Hering","fromEmail":"olaf@aepfle.de","sentAt":"2014-11-13T15:44:57Z","receivedAt":"2014-11-13T15:44:57Z","isPatch":false,"sender":{"key":"olaf@aepfle.de","avatar":"https://avatars.githubusercontent.com/u/942324?v=4"},"body":"On Thu, Nov 13, Olaf Hering wrote:\n\n> So how can I reduce the disk usage needed for the four .git dirs above?\n> I looked around in the docs that came with my git-2.1.3 package, but\n> found nothing that answers my question. Maybe we can workout something\n> and add it to one of the existing docs.\n\n\nWhile playing around with this I made some notes, this is the result:\n\n\nManage multiple branches as separate copies\n\n\nTo preserve disk space for each clone, use a master copy of the reop and do\nlocal clones from such copy of a remote repository.\n\nFirst clone the remote repository as usual. Then create a local branch for\neach remote branch that is supposed to be worked on:\n# git clone git://host/repo.git repo-master                                                                                                                                                                                                                            \n# cd repo-master                                                                                                                                                                                                                                                       \n# git checkout -b branchA origin/branchA                                                                                                                                                                                                                               \n# git checkout -b branchB origin/branchB                                                                                                                                                                                                                               \n# cd -                                                                                                                                                                                                                                                                 \n\nNow clone each work branch into its own directory. The work dir references the\nmaster repo. All changes come from and go into this repo, instead of the\nremote repo.\n# git clone -l -b branchA repo-master repo-branchA                                                                                                                                                                                                                     \n# git clone -l -b branchB repo-master repo-branchB                                                                                                                                                                                                                     \n\nTo make changs in a work dir, commit as usual. The changes will be pushed from\nthe work copy into the local master repo. Its required to have some other\nbranch than branchA active in repo-master, or push from work copy to\nrepo-master will fail.\n# cd repo-master\n# git checkout master\n# cd -\n# cd repo-branchA\n# git commit -avs\n# git push origin branchA\n# cd -\n\nTo publish the outstanding changes its required to do this from the master\nrepo. First checkout the work branch, then pull the local changes and finally\npush them to the remote repo.\n# cd repo-master\n# git checkout branchA\n# git pull\n# git push origin branchA\n# cd -\n\nTo receive changes from the remote repo its required to do this from the\nmaster repo. First checkout the work branch, then pull the outstanding remote\nchanges into the local branch. And finally pull them into the work dir.\n# cd repo-master\n# git fetch --all (optional)\n# git checkout branchB\n# git pull\n# cd -\n# cd repo-branchB\n# git pull\n# cd -\n\n\n# vim: set tw=72 et\n"},{"id":"251820","messageId":"20141113160325.GA24351@paksenarrion.iveqy.com","threadId":"37952","inReplyTo":"20141113154457.GA31624@aepfle.de","subject":"Re: how to reduce disk usage for large .git dirs?","fromName":"Fredrik Gustafsson","fromEmail":"iveqy@iveqy.com","sentAt":"2014-11-13T16:03:25Z","receivedAt":"2014-11-13T16:03:25Z","isPatch":false,"sender":{"key":"iveqy@iveqy.com","avatar":"https://avatars.githubusercontent.com/u/761743?v=4"},"body":"Thanks for sharing your notes! A few comments:\n\nOn Thu, Nov 13, 2014 at 04:44:57PM +0100, Olaf Hering wrote:\n> First clone the remote repository as usual. Then create a local branch for\n> each remote branch that is supposed to be worked on:\n> # git clone git://host/repo.git repo-master\n> # cd repo-master\n> # git checkout -b branchA origin/branchA\n> # git checkout -b branchB origin/branchB\n> # cd -\n>\n> Now clone each work branch into its own directory. The work dir references the\n> master repo. All changes come from and go into this repo, instead of the\n> remote repo.\n> # git clone -l -b branchA repo-master repo-branchA\n> # git clone -l -b branchB repo-master repo-branchB\n>\n> To make changs in a work dir, commit as usual. The changes will be pushed from\n> the work copy into the local master repo. Its required to have some other\n> branch than branchA active in repo-master, or push from work copy to\n> repo-master will fail.\n\nThat's one of the reason it's not recommended to push into a non-bare\nrepository. You should clone your repo-master with the --bare option to\navoid having a work dir there.\n\n> To publish the outstanding changes its required to do this from the master\n> repo. First checkout the work branch, then pull the local changes and finally\n> push them to the remote repo.\n> # cd repo-master\n> # git checkout branchA\n> # git pull\n> # git push origin branchA\n> # cd -\n\nIt's not. You could just add your remote repository as a remote to each\nof your clones of your master repo and push directly from them. It\nwould be much simplier and it would allow you to directly fetch changes\nfrom your remote into your branches as well.\n\n(however, I'm not sure but I think, that this will slowly increase the\ndifference between your repositories when you develop. So that they\nwon't change any new data since to local clone was made).\n\n-- \nMed vänlig hälsning\nFredrik Gustafsson\n\ntel: 0733-608274\ne-post: iveqy@iveqy.com\n"},{"id":"251821","messageId":"CALKQrgeZYs9A-GZLuRczwzRWWapmfrjFvcvR8GN+YNKxajjDRw@mail.gmail.com","threadId":"37952","inReplyTo":"20141113160325.GA24351@paksenarrion.iveqy.com","subject":"Re: how to reduce disk usage for large .git dirs?","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2014-11-13T16:08:19Z","receivedAt":"2014-11-13T16:08:19Z","isPatch":false,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"On Thu, Nov 13, 2014 at 5:03 PM, Fredrik Gustafsson <iveqy@iveqy.com> wrote:\n> Thanks for sharing your notes! A few comments:\n>\n> On Thu, Nov 13, 2014 at 04:44:57PM +0100, Olaf Hering wrote:\n>> First clone the remote repository as usual. Then create a local branch for\n>> each remote branch that is supposed to be worked on:\n>> # git clone git://host/repo.git repo-master\n>> # cd repo-master\n>> # git checkout -b branchA origin/branchA\n>> # git checkout -b branchB origin/branchB\n>> # cd -\n>>\n>> Now clone each work branch into its own directory. The work dir references the\n>> master repo. All changes come from and go into this repo, instead of the\n>> remote repo.\n>> # git clone -l -b branchA repo-master repo-branchA\n>> # git clone -l -b branchB repo-master repo-branchB\n>>\n>> To make changs in a work dir, commit as usual. The changes will be pushed from\n>> the work copy into the local master repo. Its required to have some other\n>> branch than branchA active in repo-master, or push from work copy to\n>> repo-master will fail.\n>\n> That's one of the reason it's not recommended to push into a non-bare\n> repository. You should clone your repo-master with the --bare option to\n> avoid having a work dir there.\n>\n>> To publish the outstanding changes its required to do this from the master\n>> repo. First checkout the work branch, then pull the local changes and finally\n>> push them to the remote repo.\n>> # cd repo-master\n>> # git checkout branchA\n>> # git pull\n>> # git push origin branchA\n>> # cd -\n>\n> It's not. You could just add your remote repository as a remote to each\n> of your clones of your master repo and push directly from them. It\n> would be much simplier and it would allow you to directly fetch changes\n> from your remote into your branches as well.\n>\n> (however, I'm not sure but I think, that this will slowly increase the\n> difference between your repositories when you develop. So that they\n> won't change any new data since to local clone was made).\n\nCan you not do this much simpler with --reference? Like this:\n\n  $ git clone --bare git://host/repo.git repo-master\n  $ git clone -b branchA --reference repo-master git://host/repo.git\nrepo-branchA\n  $ git clone -b branchB --reference repo-master git://host/repo.git\nrepo-branchB\n\nAll three repos now push/pull directly to/from git://host/repo.git,\nbut repo-branchA and repo-branchB reference objects from within the\nbare repo-master. You have to make use to never delete objects from\nrepo-master (if those objects happen to be referenced from\nrepo-branchA|B). If you want to prevent the repos growing in size, you\nmust devise a way to add new objects into repo-master before\nrepo-branchA|B. (e.g. a nightly cron-job in repo-master that fetches\nfrom origin), so that when repo-branchA|B pulls, they will find most\nobjects are already present in repo-master.\n\n\n...Johan\n\n-- \nJohan Herland, <johan@herland.net>\nwww.herland.net\n"},{"id":"251847","messageId":"20141113201542.GC3869@peff.net","threadId":"37952","inReplyTo":"CALKQrgeZYs9A-GZLuRczwzRWWapmfrjFvcvR8GN+YNKxajjDRw@mail.gmail.com","subject":"Re: how to reduce disk usage for large .git dirs?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2014-11-13T20:15:42Z","receivedAt":"2014-11-13T20:15:42Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Nov 13, 2014 at 05:08:19PM +0100, Johan Herland wrote:\n\n> Can you not do this much simpler with --reference? Like this:\n> \n>   $ git clone --bare git://host/repo.git repo-master\n>   $ git clone -b branchA --reference repo-master git://host/repo.git\n> repo-branchA\n>   $ git clone -b branchB --reference repo-master git://host/repo.git\n> repo-branchB\n> \n> All three repos now push/pull directly to/from git://host/repo.git,\n> but repo-branchA and repo-branchB reference objects from within the\n> bare repo-master. You have to make use to never delete objects from\n> repo-master\n\nI think the \"never delete\" part is why we usually warn people off of\nusing alternates. I think at the least you would have to \"git config\ngc.auto 0\" in the bare repository (otherwise your nightly fetches risk\npruning). Of course you'd probably want to repack eventually for\nperformance reasons. So maybe setting gc.pruneExpire is a better option\n(to something like \"20.years.ago\").\n\n> If you want to prevent the repos growing in size, you must devise a\n> way to add new objects into repo-master before repo-branchA|B. (e.g. a\n> nightly cron-job in repo-master that fetches from origin), so that\n> when repo-branchA|B pulls, they will find most objects are already\n> present in repo-master.\n\nYou can also fetch from the children into repo-master periodically.\nLike:\n\n  cd repo-master &&\n  for i in branchA branchB; do\n    git fetch ../$i +refs/*:refs/remotes/$i/*\n  done\n\nafter which it is actually safe to run \"git gc\" in the master (assuming\nthere isn't simultaneous activity in the children). This is how we\nmanage fork networks on GitHub (we take in objects to individual forks\nvia push, and then migrate them to the master repo via fetch).\n\n-Peff\n"},{"id":"251877","messageId":"20141114101427.GA1548@aepfle.de","threadId":"37952","inReplyTo":"20141113160325.GA24351@paksenarrion.iveqy.com","subject":"Re: how to reduce disk usage for large .git dirs?","fromName":"Olaf Hering","fromEmail":"olaf@aepfle.de","sentAt":"2014-11-14T10:14:27Z","receivedAt":"2014-11-14T10:14:27Z","isPatch":false,"sender":{"key":"olaf@aepfle.de","avatar":"https://avatars.githubusercontent.com/u/942324?v=4"},"body":"On Thu, Nov 13, Fredrik Gustafsson wrote:\n\n> Thanks for sharing your notes! A few comments:\n> \n> On Thu, Nov 13, 2014 at 04:44:57PM +0100, Olaf Hering wrote:\n> > First clone the remote repository as usual. Then create a local branch for\n> > each remote branch that is supposed to be worked on:\n> > # git clone git://host/repo.git repo-master\n> > # cd repo-master\n> > # git checkout -b branchA origin/branchA\n> > # git checkout -b branchB origin/branchB\n> > # cd -\n> >\n> > Now clone each work branch into its own directory. The work dir references the\n> > master repo. All changes come from and go into this repo, instead of the\n> > remote repo.\n> > # git clone -l -b branchA repo-master repo-branchA\n> > # git clone -l -b branchB repo-master repo-branchB\n> >\n> > To make changs in a work dir, commit as usual. The changes will be pushed from\n> > the work copy into the local master repo. Its required to have some other\n> > branch than branchA active in repo-master, or push from work copy to\n> > repo-master will fail.\n> \n> That's one of the reason it's not recommended to push into a non-bare\n> repository. You should clone your repo-master with the --bare option to\n> avoid having a work dir there.\n\nSo my repo-master is now \"bare\". I pushed from repo-branchA into\nrepo-master and see my commits in both repos. But pushing from\nrepo-master to the remote fails because repo-master does not have\noutstanding remote commits. However, git fetch doesnt do anything:\n\nFetching origin\nFrom host:/remote/dir\n* branch            HEAD       -> FETCH_HEAD\n\n\nObviously I miss something. The man page of git clone or fetch does not\nmention how \"bare\" is supposed to be handled.\n\nOlaf\n"},{"id":"251878","messageId":"20141114102423.GB24351@paksenarrion.iveqy.com","threadId":"37952","inReplyTo":"20141114101427.GA1548@aepfle.de","subject":"Re: how to reduce disk usage for large .git dirs?","fromName":"Fredrik Gustafsson","fromEmail":"iveqy@iveqy.com","sentAt":"2014-11-14T10:24:23Z","receivedAt":"2014-11-14T10:24:23Z","isPatch":false,"sender":{"key":"iveqy@iveqy.com","avatar":"https://avatars.githubusercontent.com/u/761743?v=4"},"body":"On Fri, Nov 14, 2014 at 11:14:27AM +0100, Olaf Hering wrote:\n> So my repo-master is now \"bare\". I pushed from repo-branchA into\n> repo-master and see my commits in both repos. But pushing from\n> repo-master to the remote fails because repo-master does not have\n> outstanding remote commits. However, git fetch doesnt do anything:\n\nAre you mixing up your branches? So that you're updating one branch in\nyour master repo but trying to push an other branch to your remote repo?\n\n-- \nMed vänlig hälsning\nFredrik Gustafsson\n\ntel: 0733-608274\ne-post: iveqy@iveqy.com\n"},{"id":"251879","messageId":"20141114103013.GC2549@aepfle.de","threadId":"37952","inReplyTo":"20141114102423.GB24351@paksenarrion.iveqy.com","subject":"Re: how to reduce disk usage for large .git dirs?","fromName":"Olaf Hering","fromEmail":"olaf@aepfle.de","sentAt":"2014-11-14T10:30:13Z","receivedAt":"2014-11-14T10:30:13Z","isPatch":false,"sender":{"key":"olaf@aepfle.de","avatar":"https://avatars.githubusercontent.com/u/942324?v=4"},"body":"On Fri, Nov 14, Fredrik Gustafsson wrote:\n\n> On Fri, Nov 14, 2014 at 11:14:27AM +0100, Olaf Hering wrote:\n> > So my repo-master is now \"bare\". I pushed from repo-branchA into\n> > repo-master and see my commits in both repos. But pushing from\n> > repo-master to the remote fails because repo-master does not have\n> > outstanding remote commits. However, git fetch doesnt do anything:\n> \n> Are you mixing up your branches? So that you're updating one branch in\n> your master repo but trying to push an other branch to your remote repo?\n\nI dont think so. I have branchA in repo-branchA, and a 'git push origin\nbranchA' puts it into repo-master. \nHow is a bare repo supposed to be updated? Is a simple 'git fetch --all'\nsupposed to work?\n\nOlaf\n"},{"id":"251881","messageId":"20141114105417.GA8954@aepfle.de","threadId":"37952","inReplyTo":"20141114103013.GC2549@aepfle.de","subject":"Re: how to reduce disk usage for large .git dirs?","fromName":"Olaf Hering","fromEmail":"olaf@aepfle.de","sentAt":"2014-11-14T10:54:18Z","receivedAt":"2014-11-14T10:54:18Z","isPatch":false,"sender":{"key":"olaf@aepfle.de","avatar":"https://avatars.githubusercontent.com/u/942324?v=4"},"body":"On Fri, Nov 14, Olaf Hering wrote:\n\n> On Fri, Nov 14, Fredrik Gustafsson wrote:\n> \n> > On Fri, Nov 14, 2014 at 11:14:27AM +0100, Olaf Hering wrote:\n> > > So my repo-master is now \"bare\". I pushed from repo-branchA into\n> > > repo-master and see my commits in both repos. But pushing from\n> > > repo-master to the remote fails because repo-master does not have\n> > > outstanding remote commits. However, git fetch doesnt do anything:\n> > \n> > Are you mixing up your branches? So that you're updating one branch in\n> > your master repo but trying to push an other branch to your remote repo?\n> \n> I dont think so. I have branchA in repo-branchA, and a 'git push origin\n> branchA' puts it into repo-master. \n> How is a bare repo supposed to be updated? Is a simple 'git fetch --all'\n> supposed to work?\n\nIs there s a slim chance that I have to fetch in repo-master before\ndoing a git push in repo-branchA? git remote show origin shows that some\nbranches are out of date.\n\nOlaf\n"},{"id":"251883","messageId":"20141114112428.GA12702@aepfle.de","threadId":"37952","inReplyTo":"20141113160325.GA24351@paksenarrion.iveqy.com","subject":"Re: how to reduce disk usage for large .git dirs?","fromName":"Olaf Hering","fromEmail":"olaf@aepfle.de","sentAt":"2014-11-14T11:24:28Z","receivedAt":"2014-11-14T11:24:28Z","isPatch":false,"sender":{"key":"olaf@aepfle.de","avatar":"https://avatars.githubusercontent.com/u/942324?v=4"},"body":"On Thu, Nov 13, Fredrik Gustafsson wrote:\n\n> That's one of the reason it's not recommended to push into a non-bare\n> repository. You should clone your repo-master with the --bare option to\n> avoid having a work dir there.\n\nEven if I do a fresh clone with --bare, the result can not be updated\nanymore with git fetch. What I'm doing wrong?\n\nOlaf\n"},{"id":"251884","messageId":"5465F649.4090906@gmail.com","threadId":"37952","inReplyTo":"20141113120313.GB15503@aepfle.de","subject":"Re: how to reduce disk usage for large .git dirs?","fromName":"Jakub Narębski","fromEmail":"jnareb@gmail.com","sentAt":"2014-11-14T12:32:09Z","receivedAt":"2014-11-14T12:32:09Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"W dniu 2014-11-13 13:03, Olaf Hering pisze:\n > On Thu, Nov 13, Fredrik Gustafsson wrote:\n[...]\n>> Your setup looks familiar to me for a subversion user switching to git\n>> and trying to use git as subversion. The common usecase is not to have\n>> multiple worktrees but to do a checkout to the worktree you need to work\n>> on. This is possible with git since it's very fast and I recommend you\n>> to try to use one worktree.\n\n> Switching branches will invalidate timestamps, causing a full rebuild.\n\nWouldn't a better way of solving \"full rebuild\" issue be to use ccache \nor similar solution?\n\nAnyway, switching branches invalidates timestamps only on those files \nthat change between branches -- it is to avoid unnecessary rebuilds.\n\nYou can always clone with --reference, and use alternates (alternate \nobject store). Just don't delete objects in repository that other \nrepositories borrow from; GitHub uses refs/borrowers/ namespace for \nthat, IIRC.\n\nHTH\n-- \nJakub Narębski\n"},{"id":"251886","messageId":"8761ehom8l.fsf@igel.home","threadId":"37952","inReplyTo":"20141114112428.GA12702@aepfle.de","subject":"Re: how to reduce disk usage for large .git dirs?","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2014-11-14T15:06:18Z","receivedAt":"2014-11-14T15:06:18Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Olaf Hering <olaf@aepfle.de> writes:\n\n> Even if I do a fresh clone with --bare, the result can not be updated\n> anymore with git fetch. What I'm doing wrong?\n\nA --bare clone has no connection to its origin (there are no remotes).\nYou want a --mirror.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"252521","messageId":"20141125143259.GA9794@aepfle.de","threadId":"37952","inReplyTo":"8761ehom8l.fsf@igel.home","subject":"Re: how to reduce disk usage for large .git dirs?","fromName":"Olaf Hering","fromEmail":"olaf@aepfle.de","sentAt":"2014-11-25T14:32:59Z","receivedAt":"2014-11-25T14:32:59Z","isPatch":false,"sender":{"key":"olaf@aepfle.de","avatar":"https://avatars.githubusercontent.com/u/942324?v=4"},"body":"On Fri, Nov 14, Andreas Schwab wrote:\n\n> Olaf Hering <olaf@aepfle.de> writes:\n> \n> > Even if I do a fresh clone with --bare, the result can not be updated\n> > anymore with git fetch. What I'm doing wrong?\n> \n> A --bare clone has no connection to its origin (there are no remotes).\n> You want a --mirror.\n\nUsing --mirror for this purpose is dangerous because it will most likely\noverwrite changes on the remote side. Fortunately I used 'git push --dry-run\norigin' and the output was like:\n\nTo git://host/repo.git\n + abbrev1..abbrev2 branchA -> branchA (forced update)\n\nBefore that I pushed already to the remote repo without realizing where the\npush goes to.\n\nLooks like using the --bare option for cloning the master and then doing\nsomething like \"git clone --origin local_bare -b branchA --reference\nrepo-master git://host/repo.git repo-branchA\" will work better.\n\nOlaf\n"}]}