Subject: Re: how to reduce disk usage for large .git dirs?

From: Olaf Hering <[email-masked]>
Date: Thu, 13 Nov 2014 16:44:57 +0100

On Thu, Nov 13, Olaf Hering wrote:

> So how can I reduce the disk usage needed for the four .git dirs above?
> I looked around in the docs that came with my git-2.1.3 package, but
> found nothing that answers my question. Maybe we can workout something
> and add it to one of the existing docs.

While playing around with this I made some notes, this is the result:

Manage multiple branches as separate copies

To preserve disk space for each clone, use a master copy of the reop and do
local clones from such copy of a remote repository.

First clone the remote repository as usual. Then create a local branch for
each remote branch that is supposed to be worked on:
# git clone git://host/repo.git repo-master                                                                                                                                                                                                                            
# cd repo-master                                                                                                                                                                                                                                                       
# git checkout -b branchA origin/branchA                                                                                                                                                                                                                               
# git checkout -b branchB origin/branchB                                                                                                                                                                                                                               
# cd -                                                                                                                                                                                                                                                                 

Now clone each work branch into its own directory. The work dir references the
master repo. All changes come from and go into this repo, instead of the
remote repo.
# git clone -l -b branchA repo-master repo-branchA                                                                                                                                                                                                                     
# git clone -l -b branchB repo-master repo-branchB                                                                                                                                                                                                                     

To make changs in a work dir, commit as usual. The changes will be pushed from
the work copy into the local master repo. Its required to have some other
branch than branchA active in repo-master, or push from work copy to
repo-master will fail.
# cd repo-master
# git checkout master
# cd -
# cd repo-branchA
# git commit -avs
# git push origin branchA
# cd -

To publish the outstanding changes its required to do this from the master
repo. First checkout the work branch, then pull the local changes and finally
push them to the remote repo.
# cd repo-master
# git checkout branchA
# git pull
# git push origin branchA
# cd -

To receive changes from the remote repo its required to do this from the
master repo. First checkout the work branch, then pull the outstanding remote
changes into the local branch. And finally pull them into the work dir.
# cd repo-master
# git fetch --all (optional)
# git checkout branchB
# git pull
# cd -
# cd repo-branchB
# git pull
# cd -

# vim: set tw=72 et