Maven / GitLab CI Basics Interview Questions
What is the 'GIT_STRATEGY' variable in GitLab CI and what are the options?
The GIT_STRATEGY variable controls how GitLab CI fetches your repository's code at the start of each job. Choosing the right strategy balances freshness of code against job startup speed.
| Value | Behaviour | Speed | Use case |
|---|---|---|---|
| fetch (default) | Fetches only new commits; reuses existing clone | Fast | Most jobs |
| clone | Full fresh clone every time | Slow | When clean state is required |
| none | Skips Git entirely; no repo code | Fastest | Jobs that don't need repo code (deploy from artifact) |
# Set globally for all jobs: variables: GIT_STRATEGY: fetch # default - fast incremental fetch # Override for a specific job: clean-build: variables: GIT_STRATEGY: clone # ensure completely fresh checkout script: - make clean && make build # Skip checkout for deploy-only jobs: deploy-from-artifact: variables: GIT_STRATEGY: none # no git checkout needed script: - echo "Using artifact from build job..." - ls dist/ # artifact already downloaded - ./deploy.sh # Related: control submodule fetching variables: GIT_SUBMODULE_STRATEGY: normal # clone/fetch submodules too
GIT_DEPTH: the related variable GIT_DEPTH controls shallow clone depth. Setting GIT_DEPTH: "1" fetches only the latest commit (no history), which is significantly faster for large repositories. Setting it to 0 disables shallow cloning and fetches full history.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
