git clone --depth 1 repo.git
# --single-branch is implied
--depth <depth>
Create a shallow clone with a history truncated to the specified number of commits. Implies --single-branch unless --no-single-branch is given to
fetch the histories near the tips of all branches. This implies --shallow-submodules. If you want to have a shallow superproject clone, but full
submodules, also pass --no-shallow-submodules.
Note: Don't unshallow a repo, it's better to re-clone
(GitHub run this on repos once a week or so)
Note: Issues with git gc --aggressive
git gc
Runs a number of housekeeping tasks within the current repository, such as compressing file revisions (to reduce disk space and increase performance) and
removing unreachable objects which may have been created from prior invocations of git add.
Users are encouraged to run this task on a regular basis within each repository to maintain good disk space utilization and good operating performance.
Some git commands may automatically run git gc; see the --auto flag below for details.
BGF Repo-Cleaner (An alternative to git filter-branch)
CocoaPods being bit by Git shallow clones
Scaling git at Atlassian with Atlassian Stash
Why Google Stores Billions of Lines of Code in a Single Repository
Git at Google: Making Big Projects (and Everyone Else) Happy, Dave Borowitz - Git Merge 2015