how to make a shallow clone a full repository

You can make a shallow clone in the first place (useful if you are in a place with a tenuous or slow internet connection) like this:

git clone --depth 1 git@git.example.com/repo.git

You can later make it a complete repository, with history and branches, like this:

git fetch --unshallow
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git fetch origin

This only applies to modern Git.

Via https://stackoverflow.com/a/17937889/1028376