2

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
  • No. Shallow-ness, or lack thereof, is driven from the client side only and there's no advisory "here's how deep you should clone" option from server to client. Commented May 27, 2020 at 20:11
  • "Many large commits" makes me think you've got media files in there. If so, convert your repo to use git lfs or git annex to get the effect you're after. Commented May 27, 2020 at 23:35

2 Answers 2

2

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)

Sign up to request clarification or add additional context in comments.

Comments

1

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...

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.