Possible to create a full git clone on an agent including all remote branches/tags?


We are using: TeamCity Enterprise 9.1.6 (build 37459)

We need to be able to do a full git clone on our agents. We have configured checkout mode to : "Using Automatically on agent":


but it will only do a single branch checkout to optimize speed/space required - it does create a .git folder making it possible to do local git operations for that branch in the TC working directory. But we need a fully operational git clone with all remote branches/tags in the working directory.

Is it possible to configure TC to do this? Based on


I tried to set  teamcity.git.use.shallow.clone=false both as configuration, system and environment variable/parameter but it has no effect.

We currently store the credentials on each agent and call git.exe in a command line step but would like to avoid this if possible.




Comment actions Permalink

Hi Johannes,

It is not possible in TeamCity now. We have the related request https://youtrack.jetbrains.com/issue/TW-24878, please watch and vote. Only available workaround at the moment is to run fetch manually as a first build step. 
Could you please provide details of your use case? Why do you need to clone all branches?

Comment actions Permalink

One use case I need to support is to run sonar preview analysis on every Pull Request before allowing to merge to the source branch.

Let's say master is my main branch.
I create a feature branch from master.
I am doing the code and submitting a pull request.
Before to allow squashing and merging my pull request into master some automatic checks need to pass: a reviewer has approved the code, The teamcity build passed AND the sonar preview analysis has reported no issues (sonar analysis are running on code changed or added).

For this last check, the sonar plugin needs to use the git blame feature: https://docs.sonarqube.org/display/PLUG/Git+Plugin (cf. known issues) and needs a full clone of the code on the agent.

Comment actions Permalink


Since TeamCity 10.0.4 you can make git-plugin to fetch all heads by adding a build configuration parameter 'teamcity.git.fetchAllHeads=true'.

Comment actions Permalink

Hi, Alina.


I've added this to my build configuration but TeamCity is still not fetching all the remote branches.

Can you please point me to the documentation of this feature?

Thank you

Comment actions Permalink

Alina, which version is that? We are running 
TeamCity Enterprise 2017.2 (build 50574)

So I have no idea which version that corresponds to.


Please sign in to leave a comment.