I have an Azure Pipeline (yaml) which uses templates and I'm trying to figure out how to setup the fetch depth of the actual repository being cloned.
resources:
repositories:
- repository: templates
type: git
name: 'DevOps/CICD'
ref: refs/heads/develop
- repository: self # sic!
fetchDepth: 1
clean: true`
Fetch depth is supported (vscode extension) but I can't seem to find any extensive documentation on it..
This is an untenable waste of bandwidth for deployments. The git documentation says you cannot fetch from a shallow repository, though that's strictly not true. Are there any workarounds to make a git clone --depth 1 able to fetch just what's changed from it?
You can deepen a shallow repository with "git-fetch --depth 20 repo branch", which will fetch branch from repo, but stop at depth 20, updating $GIT_DIR/shallow. The special depth 2147483647 (or 0x7fffffff, the largest positive number a signed 32-bit integer can contain) means infinite depth.
We can't distribute the full repository since it's too large (>2GB), so we have been using shallow clones (~300M). However recently when fetching from a shallow clone, it's now inefficiently fetches the entire >2GB repository. This is an untenable waste of bandwidth for deployments.
Git shallow clone lets you pull down just the latest commits, not the entire repo history. So if your project has years of history, or history from thousands of commits, you can select a particular depth to pull. How to Execute Git Shallow Clone Provide an argument of -- depth 1 to the git clone command to copy only the latest revision of a repo:
Placing this under steps
works for me:
steps:
- checkout: self
fetchDepth: 1
clean: true
- task: NuGetCommand@2
...
Results in:
2019-01-17T09:21:45.1133753Z ##[command]git -c http.extraheader="AUTHORIZATION: bearer ***" fetch --tags --prune --progress --no-recurse-submodules --depth=1 origin
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With