# Git-lfs caching, is it possible?

**URL:** <https://discuss.bitrise.io/t/git-lfs-caching-is-it-possible/3570>\
**Category:** Question & Answer\
**Created:** [December 20, 2017, 2:39pm UTC](https://discuss.bitrise.io/t/git-lfs-caching-is-it-possible/3570 "2017-12-20T14:39:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![scspijker](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@scspijker](https://discuss.bitrise.io/u/scspijker)\
**Post date:** [December 20, 2017, 2:39pm UTC](https://discuss.bitrise.io/t/git-lfs-caching-is-it-possible/3570/1 "2017-12-20T14:39:05Z")

</div>

We’ve recently started using git’s LFS (Large File Support) extension. Our repository is running on GitHub.  
We ran into some issues where we went over our quota on GitHub because Bitrise seems to be downloading the LFS dependencies over and over again, which will rapidly become very expensive for us.

Is there some way to cache the git-lfs dependencies between builds?

I have found a caching article for cocoapods with the cache steps in a workflow, but git-lfs work during the `git clone` phase, so I don’t know if this will work for us…

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [December 22, 2017, 7:41am UTC](https://discuss.bitrise.io/t/git-lfs-caching-is-it-possible/3570/2 "2017-12-22T07:41:04Z")

</div>

Hi @scspijker,

Sure, it’s definitely possible. As git LFS is just a `git` “plugin”, the same rules apply for it as with the git repo itself.

This means that it’s not possible to only cache the LFS files without the rest of the repository, without extensive tweaking. But you can of course cache the whole repo, including the LFS files. You can find the related #How To guide here:

> [@How to Cache the Source Code directory](http://discuss.bitrise.io/t/how-to-cache-the-source-code-directory/1533):
>
> Bitrise does not do automatic git/source code caching, unless you configure it for yourself. This is part of our Security policy too (that we don’t store your code and we never access it outside of the ephemeral build VMs): [Redirecting…](http://devcenter.bitrise.io/getting-started/code-security/#source-code) You can of course configure the source to be cached, a very simple / minimal example: workflows: primary: steps: - activate-ssh-key@3.1.1: - cache-pull@0.9.2: {} - git-clone@3.4.3: inputs: - reset\_repository: 'Yes' - cache-…

If you’d have any questions, issues or feedback just let us know! 😉

---

<div class="post-metadata">

**Author:** ![scspijker](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@scspijker](https://discuss.bitrise.io/u/scspijker)\
**Post date:** [December 22, 2017, 9:13am UTC](https://discuss.bitrise.io/t/git-lfs-caching-is-it-possible/3570/3 "2017-12-22T09:13:50Z")

</div>

Cool, thanks!  
I’ve added the caching step per instructions and will report back whether this helps our bandwidth issues 🙂

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [December 23, 2017, 8:00am UTC](https://discuss.bitrise.io/t/git-lfs-caching-is-it-possible/3570/4 "2017-12-23T08:00:29Z")

</div>

> [@scspijker](#):
>
> I’ve added the caching step per instructions and will report back whether this helps our bandwidth issues 🙂

Thanks, please definitely do, I’m interested 😉

---

<div class="post-metadata">

**Author:** ![scspijker](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@scspijker](https://discuss.bitrise.io/u/scspijker)\
**Post date:** [January 3, 2018, 8:52am UTC](https://discuss.bitrise.io/t/git-lfs-caching-is-it-possible/3570/5 "2018-01-03T08:52:24Z")

</div>

Definitely looks like this is working. Our bandwidth is not used exponentially anymore, and Bitrise build still reliable 👍 Thnx

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [January 5, 2018, 9:35am UTC](https://discuss.bitrise.io/t/git-lfs-caching-is-it-possible/3570/6 "2018-01-05T09:35:22Z")

</div>

Glad to hear, thanks for reporting @scspijker! 🙂

---

<div class="post-metadata">

**Author:** ![bootstraponline](https://avatars.discourse-cdn.com/v4/letter/b/c68b51/32.png) [@bootstraponline](https://discuss.bitrise.io/u/bootstraponline)\
**Post date:** [September 24, 2018, 7:10pm UTC](https://discuss.bitrise.io/t/git-lfs-caching-is-it-possible/3570/7 "2018-09-24T19:10:18Z")

</div>

I ran into an issue with the git clone step not playing nice with the cache:

> <https://github.com/bitrise-steplib/steps-git-clone/issues/86>
>
> \`\`\`
> +--------------------------------------------------------------------------…----+
> 
> | (3) git-clone |
> +------------------------------------------------------------------------------+
> | id: git-clone |
> | version: 4.0.12 |
> | collection: https://github.com/bitrise-io/bitrise-steplib.git |
> | toolkit: go |
> | time: 2018-09-24T12:04:35-07:00 |
> +------------------------------------------------------------------------------+
> | |
> INFO\[12:04:35\] \* \[OK\] Step dependency (go) installed, available. 
> config:
> \- RepositoryURL: git@github.com:instructure/ios.git
> \- CloneIntoDir: /Users/vagrant/git
> \- Commit: b3c43b3abdd50a048ef94acfa4e33fe293b169a8
> \- Tag: 
> \- Branch: earlgrey\_2
> \- BranchDest: master
> \- PRID: 2313
> \- PRRepositoryURL: git@github.com:instructure/ios.git
> \- PRMergeBranch: pull/2313/merge
> \- ResetRepository: true
> \- CloneDepth: 0
> \- BuildURL: https://app.bitrise.io/build/24f418723816bac6
> \- BuildAPIToken: \[REDACTED\]
> \- UpdateSubmodules: true
> \- ManualMerge: true
> git "init"
> Initialized empty Git repository in /Users/vagrant/git/.git/
> git "remote" "add" "origin" "git@github.com:instructure/ios.git"
> git "fetch" "origin" "master"
> Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
> From github.com:instructure/ios
> \* branch master -\> FETCH\_HEAD
> \* \[new branch\] master -\> origin/master
> git "checkout" "master"
> error: The following untracked working tree files would be overwritten by checkout:
> scripts/ftl/.gitignore
> scripts/ftl/ios\_student\_ftl.sh
> scripts/ftl/ios\_teacher\_ftl.sh
> scripts/ftl/ios\_teacher\_run.sh
> Please move or remove them before you switch branches.
> Aborting
> ERROR: manual merge, error: pull failed (master), error: checkout failed (master), error: exit status 1
> | |
> +---+---------------------------------------------------------------+----------+
> | x | git-clone (exit code: 1) | 13 sec |
> +---+---------------------------------------------------------------+----------+
> | Issue tracker: https://github.com/bitrise-io/steps-git-clone/issues |
> | Source: https://github.com/bitrise-io/steps-git-clone |
> +---+---------------------------------------------------------------+----------+
> \`\`\`
> 
> untracked working tree files are not being removed.

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [November 26, 2018, 5:49pm UTC](https://discuss.bitrise.io/t/git-lfs-caching-is-it-possible/3570/8 "2018-11-26T17:49:09Z")

</div>

Bumped the related task’s priority in our backlog!
