Make a shallow GIT repository less shallow
I create a shallow clone for a specified tag:
After this the cloned repo only has the tag v0.1.3 (and associated files) in it.
It does not have the history for all the changes before or after that tag (as I understand – correct me if wrong.)
Next I would like to update the clone to include v0.1.4.
If I use a “git fetch –unshallow” command, then I get the full history, which I do not want.
Is there a way to expand my clone to include newer history from the master (like v0.1.4 and 0.1.5), but not older history (like 0.1.2)? (I see an option called update-shallow, but do not understand what it does or whether it is relevant.)
The goal of this is:
1) Make the initial setup of the repository on the remote server fast and small by not cloning the whole repo. (Our repo is mostly binaries: DLLs, EXEs.)
2) Make it possible to upgrade the remote repo to later versions (as given by the tag) but never earlier versions. Such an upgrade will only transfer a fraction of the repository, so it should also be fast.
NOTE: My Git version is 1.9.2.msysgit.0 on Windows 7. This includes the recent enhancements to shallow cloning.
We will likely host the main repository on Linux, but the agents to which we deploy run Windows.
The intent is to manage checkouts using puppet enterprise.
Tried VonC’s suggestion.
$ git fetch --update-shallow origin v0.1.4 remote: Counting objects: 6, done. remote: Compressing objects: 100% (4/4), done. remote: Total 4 (delta 2), reused 0 (delta 0) Unpacking objects: 100% (4/4), done. From file:///c/usr/sites/smc * tag v0.1.4 -> FETCH_HEAD paul.chernoch@USB-XXXXXXXXX /c/usr/sites/smc-clone3 ((v0.1.3)) $ git describe v0.1.3 paul.chernoch@USB-XXXXXXXXX /c/usr/sites/smc-clone3 ((v0.1.3)) $ git tag --list v0.1.3
While the command seemed to do something, I do not see the tag v0.1.4 in my target repo. However, if I use the –tags option, I get all the tags, but also all the history!
Also, I do not understand the notation “FETCH_HEAD” in the output of the git fetch command.
Further research shows that this SO question is after a similar goal:
git shallow clone to specific tag
One Solution collect form web for “Make a shallow GIT repository less shallow”
Seems I had a similar question to this and found this afterwards. The trick was to specify the full refspec at the end and depth on the fetch command. refs/tags/v0.1.3:refs/tags/v0.1.3 or tag v0.1.3 for short
Git shallow fetch of a new tag
git fetch --depth 1 origin tag v0.1.4