Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shallow fetch for repository

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

like image 440
grmbl Avatar asked Jan 17 '19 08:01

grmbl


People also ask

Is it possible to fetch from a shallow Git repository?

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?

How to deepen a shallow repository?

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.

Why are shallow clones no longer fetching the full repository?

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.

What is a Git shallow clone?

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:


Video Answer


1 Answers

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

like image 74
grmbl Avatar answered Oct 03 '22 01:10

grmbl