Cache .git versus persist_to_workspace

Using the v2.0, I’m caching my .git directory in the build job, then in subsequent jobs I’m retrieving the cache and checkout it out. Wouldn’t it be fast to just persist to workspace the working directory? (The answer is yes, because I’ve tried it, I’m just not sure why the docs seems to suggest otherwise)

Where in the Docs do you see this?

What is the ultimate point in moving your .git/ directory into additional jobs?

It’s referenced in the docs: https://circleci.com/docs/2.0/caching/#source-caching

I’m still definitely interested in this idea. I’m getting the sense from @FelicianoTech 's comment that this is not actually the recommended way to persist a codebase through jobs.

The idea behind this is to cache your Git repo for pulling from GitHub via the checkout step. The Workspaces Doc shows that Workspaces typically are the fastest way to move data between jobs.

Please note that the checkout step is currently broken when caching the .git directory and you try to build a tag:

that makes sense, thanks.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.