# 1. clone remote git

mkdir IUGIT
git clone git@github.com:compucell3d/CompuCell3D.git .

# fetch and establish all remote branches
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master`; do
    git branch --track ${branch##*/} $branch
done


# make bundle backup 
git bundle create ~/IUGIT_BUNDLE.dat --all


# http://stackoverflow.com/questions/10292903/git-on-windows-out-of-memory-malloc-failed
# to avoid problems with memory allocatin during repack, gc prune operations etc
git config --global pack.threads 1
git config --global pack.windowMemory 256m

# Alternatively
# In .git/config file (client and/or server) I added the following:

# [core]
  # packedGitLimit = 128m
  # packedGitWindowSize = 128m

# [pack]
  # deltaCacheSize = 128m
  # packSizeLimit = 128m
  # windowMemory = 128m

#cleaning up content of unwanted directories
git filter-branch --tag-name-filter cat --index-filter 'git rm -r --cached --ignore-unmatch 2.1.0/*   3.2.0/*  3.2.2/*  3.3.1/*  3.4.05/*  3.4.2/* 3.5.0/*  3.6.0/*  3.6.2/* twedit/*    Workshop08/* 3.1.18/*  3.2.1/*  3.3.0/*  3.4.0/*  3.4.1/* 3.4.4-unstable/*  3.5.1/*  3.6.1/* PIF_Generator/*  src-parallel/*  twedit++/* ' --prune-empty -f -- --all

# running cleanup using garbage collector
rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now
git gc --aggressive --prune=now