git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Roger Gammans <roger@gammascience.co.uk>
To: Olaf Hering <olaf@aepfle.de>
Cc: git@vger.kernel.org
Subject: Re: how to reduce disk usage for large .git dirs?
Date: Thu, 13 Nov 2014 12:02:29 +0000	[thread overview]
Message-ID: <1415880149.4825.43.camel@knuth.computer-surgery.co.uk> (raw)
In-Reply-To: <20141113111444.GA15503@aepfle.de>

On Thu, 2014-11-13 at 12:14 +0100, Olaf Hering wrote:
> How can I reduce the disk usage for multiple copies of the same repo?
> 
> Up to now I just made copies like this, but since .git alone is already
> 2GB it becomes expensive:
> 
>  # git clone git://host/repo.git repo-master
>  # cp -a repo-master repo-branchA
>  # cd repo-branchA
>  # git checkout -b branchA origin/branchA
>  # cd -
>  # cp -a repo-master repo-branchB
>  # cd repo-branchB
>  # git checkout -b branchB origin/branchB
>  # cd -
>  # cp -a repo-master repo-branchB-feature
>  # cd repo-branchB-feature
>  # git checkout -b branchB-feature origin/branchB
>  # cd -
> 
> 
> Since each .git is almost identical I wonder if there is a reliable way
> to "share" it. The "git clone" man page mentions --shared as a dangerous
> way to do things. It does not give an advice how to manage such cloned
> trees.

But you're not using clone you are using cp .

The clone man page also says this:-
      --local, -l
           When the repository to clone from is on a local machine, this flag bypasses the normal "Git aware" transport
           mechanism and clones the repository by making a copy of HEAD and everything under objects and refs directories. The
           files under .git/objects/ directory are hardlinked to save space when possible.

           If the repository is specified as a local path (e.g., /path/to/repo), this is the default, and --local is essentially
           a no-op. If the repository is specified as a URL, then this flag is ignored (and we never use the local
           optimizations). Specifying --no-local will override the default when /path/to/repo is given, using the regular Git
           transport instead.


Note the first sentence of the second paragraph.
 eg:
 # git clone git://host/repo.git repo-master
 # git clone repo-master repo-branchA
 # cd repo-branchA
 # git checkout -b branchA origin/branchA
 # cd -
 # git clone repo-master repo-branchB
 # cd repo-branchB
 # git checkout -b branchB origin/branchB
 # cd -
 # git clone repo-master repo-branchB-feature
 # cd repo-branchB-feature
 # git checkout -b branchB-feature origin/branchB
 # cd -

Should work better for you. And there is probably a way to do it less
commands too.

-- 
Roger Gammans <roger@gammascience.co.uk>

  parent reply	other threads:[~2014-11-13 12:40 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-13 11:14 how to reduce disk usage for large .git dirs? Olaf Hering
2014-11-13 11:49 ` Fredrik Gustafsson
2014-11-13 12:03   ` Olaf Hering
2014-11-14 12:32     ` Jakub Narębski
2014-11-13 12:02 ` Roger Gammans [this message]
2014-11-13 12:21   ` Olaf Hering
2014-11-13 12:09 ` Duy Nguyen
2014-11-13 15:44 ` Olaf Hering
2014-11-13 16:03   ` Fredrik Gustafsson
2014-11-13 16:08     ` Johan Herland
2014-11-13 20:15       ` Jeff King
2014-11-14 10:14     ` Olaf Hering
2014-11-14 10:24       ` Fredrik Gustafsson
2014-11-14 10:30         ` Olaf Hering
2014-11-14 10:54           ` Olaf Hering
2014-11-14 11:24     ` Olaf Hering
2014-11-14 15:06       ` Andreas Schwab
2014-11-25 14:32         ` Olaf Hering

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1415880149.4825.43.camel@knuth.computer-surgery.co.uk \
    --to=roger@gammascience.co.uk \
    --cc=git@vger.kernel.org \
    --cc=olaf@aepfle.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).