Answers: <p>Use a Git <a href="https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks" rel="noreferrer">post-receive hook</a> to issue a <code>git pull</code> in the directory you want to keep updated. You might want to mount the directory you want to keep updated locally to the Git server, or execute that command remotely with <code>ssh</code> into Git Bash on Windows, or Powershell. Alternatively have the hook call a webhook and have the webhook execute the <code>git pull</code>. The webhook method will be easiest with BitBucket, I don't know about the others.</p>
  
Answers: CC BY-SA 3.0
Answers: 2017-10-24T20:18:15.603Z
Answers: 2017-10-24T20:18:15.603Z
Answers: Gaius
Answers: <p>The standard pattern for this is to have a build that is triggered upon change to the git repository.  The build will do nothing more than checkout the repository and make an archive of everything but the .git folder, then upload that to whatever file server(s) make(s) it available to all the things that need it.  Implementation specifics depend on the git server, build server, file server, and build tool chosen but this should be trivial to implement in almost all cases.</p>
  
Answers: CC BY-SA 3.0
Answers: 2017-10-24T20:11:39.157Z
Answers: 2017-10-24T20:11:39.157Z
Answers: M. Ayers
Body: <p>I wonder if anyone knows of a tool or method that I can use to accomplish my goal of having a folder that always contains a copy of the latest code from my Git repository.</p>
  
  <p>I need it to work generically with Git, as it may be hosted on VisualStudio.com, Bitbucket, GitHub or any other Git provider.</p>
  
  <p>Background: I have a requirement to keep all the latest code in a big data store in Azure. It will be hundreds of repositories, frequently adding more. I find it more scalable to download the code from a folder rather than integrating directly with Git with that many repositories. So I am looking for some existing method or tool to go in-between and place a copy of the latest code from my Git repository in a folder.</p>
  
Tags: <git><azure>
Title: Need a folder, always updated with the latest code from Git
UserDisplayName: Niels Brinch
ThreadText: # Need a folder, always updated with the latest code from Git
  
  (Asked by: username_0 on 2017-10-24)
  
  I wonder if anyone knows of a tool or method that I can use to accomplish my goal of having a folder that always contains a copy of the latest code from my Git repository.
  
  I need it to work generically with Git, as it may be hosted on VisualStudio.com, Bitbucket, GitHub or any other Git provider.
  
  Background: I have a requirement to keep all the latest code in a big data store in Azure. It will be hundreds of repositories, frequently adding more. I find it more scalable to download the code from a folder rather than integrating directly with Git with that many repositories. So I am looking for some existing method or tool to go in-between and place a copy of the latest code from my Git repository in a folder.
  
  **Tags:** git, azure
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2017-10-24. Score: 6
  
  Use a Git [post-receive hook](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) to issue a `git pull` in the directory you want to keep updated. You might want to mount the directory you want to keep updated locally to the Git server, or execute that command remotely with `ssh` into Git Bash on Windows, or Powershell. Alternatively have the hook call a webhook and have the webhook execute the `git pull`. The webhook method will be easiest with BitBucket, I don't know about the others.
  
  
  ---
  
  ### Answer by username_2 on 2017-10-24. Score: 4
  
  The standard pattern for this is to have a build that is triggered upon change to the git repository. The build will do nothing more than checkout the repository and make an archive of everything but the .git folder, then upload that to whatever file server(s) make(s) it available to all the things that need it. Implementation specifics depend on the git server, build server, file server, and build tool chosen but this should be trivial to implement in almost all cases.
  
  
  ---
  
  