title: Download Source files of a specific directory under Azure DevOps Git Monorepo
body: <p>I have a Git monorepo which has two folders (two separate solutions) in it. I have set two CI builds for each solution. Each CI has the <code>Enable Continuous Integration</code> activated. For each CI pipeline, I have specified <code>Path filters</code> (Exclude) for each folder so as to prevent CI builds for any commit for the other folder.</p>
  
  <p>Is there a way for the private agent to download <strong>ONLY</strong> the source files [under a folder] which got affected by a commit?</p>
  
  <p><a href="https://i.stack.imgur.com/vfXoS.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vfXoS.jpg" alt="enter image description here"></a></p>
  
  <p>That is, when the <em>Database</em> folder gets a commit, the agent downloads only the source files under the <em>Database</em> folder.</p>
  
  <p>Is this related to <code>Checkout submodules</code>?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>This is my PowerShell script:</p>
  
  <pre><code>cd $(Build.SourcesDirectory)
  
  git config --global user.email "my_email_here"
  git config --global user.name "my_username_here"
  
  git init
  git remote add origin -f https://my_username_here@dev.azure.com/my_username_here/TxProject/_git/testtwoprojects
  git config core.sparseCheckout true
  Set-Content -Path .git/info/sparse-checkout -Value "Source/*"
  git pull origin master
  </code></pre>
  
  <p>The error I receive is:</p>
  
  <blockquote>
    <p>git : fatal: InvalidOperationException encountered. At
    C:\agent_work_temp\b5feb3b7-f104-48a0-94d8-a8c769e84a6e.ps1:8 char:1
    + git remote add origin -f <a href="https://my_username_here@dev.azure.com/my_username_here/TxProjec" rel="nofollow noreferrer">https://my_username_here@dev.azure.com/my_username_here/TxProjec</a> ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (fatal: InvalidO...on encountered.:String) [], RemoteException
        + FullyQualifiedErrorId : NativeCommandError   PowerShell exited with code '1'.</p>
  </blockquote>
  
  <p><strong>SOLUTION</strong></p>
  
  <p>I found a solution. First I changed to a Command Line task (from PowerShell) and added <code>2&gt;&amp;1</code> at the end of the commands.</p>
  
  <p>Final code is:</p>
  
  <pre><code>cd $(Build.SourcesDirectory)
  
  git config --global user.email "user_email"
  git config --global user.name "user_name"
  
  git init
  git remote add origin -f LINK_TO_REPO 2&gt;&amp;1
  git config core.sparseCheckout true
  echo Source/ &gt;&gt; .git/info/sparse-checkout
  git pull origin master 2&gt;&amp;1
  </code></pre>