I have a repository with many large commits. Most people who clone my repository are probably only interested in the latest version. However, the default git clone command downloads all previous versions. Is there a setting that I can change in my repository, so that git clone --depth 1 becomes the default for anyone cloning the repo?
2 Answers
The is no configuration setting that the client might set globally or locally to force a depth of 1 during a clone.
Only the git clone --depth command can make a shallow clone, on demand by the client.
As noted, using Git LFS can help (in order to not checkout large files), but that would not help if your issue is a large number of commit (where you want to limit the amount of commit fetched)
Comments
For anyone later has similar requirement, I write a shell script to warp git, which is used for client
# the path will vary in your host mv /usr/bin/git /usr/bin/git1 cat <<-'EOF' > /usr/local/bin/git #!/bin/bash set -e args=("$@") if [ "${args[0]}" == "clone" ]; then echo "Cloning with depth 1" /usr/bin/git1 clone --depth 1 "${args[@]:1}" else exec /usr/bin/git1 "${args[@]}" fi EOF chmod +x /usr/local/bin/git It's kind of goofy workaround but works for me...
git lfsorgit annexto get the effect you're after.