You are viewing the documentation of TeamCity 2018.x, which is not the most recently released version of TeamCity.
View this page in the latest documentation or refer to the listing to choose the documentation corresponding to your TeamCity version.


Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.

Wiki Markup
{alias:Git (JetBrains)}
TeamCity supports Git out of the box. Git source control with Visual Studio Team Services is supported (see authentication notes below).

This page contains description of the Git-specific fields of the VCS root settings.
For common VCS Root properties, see this section.




Path to git

Provide the path to a git executable to be used on the agent. When set to %env.TEAMCITY_GIT_PATH%, the automatically detected git will be used, see Git executable on the agent for details

Clean Policy/Clean Files Policy

Specify here when the "git clean" command is to run on the agent, and which files are to be removed.

Use mirrors

When enabled (default), TeamCity clones the repository under the agent's system\git directory and uses the mirror as an alternate repository when updating the checkout directory for the build. As a result, this speeds-up clean checkout (because only the working directory is cleaned), and saves disk space (as there is only one clone of the given git repository on an agent).


TeamCity executes Git garbage collection until the total time doesn't exceed 60 minutes quota; the quota can be changed using the teamcity.server.git.gc.quota.minutes internal property.
Git garbage collection is executed every night at 2 a.m., this can be changed by specifying the internal property with a cron expression like this: "teamcity.git.cleanupCron=0 0 2 * * ?" (restart the server for the property to take effect)

If git gc process is slow and cannot be finished within allotted time, check git-repack configuration in the default git configuration files. e.g. "--window-memory" can be increased to improve git gc performance.

When Git gc is configured, TeamCity will run automatically in the background it for all currently monitored VCS roots.
With large Git repositories, if git gc has not been performed for a long time, garbage collection may take significant time.
Alternatively, you can stop TeamCity and delete the entire content of <TeamCity Data Directory>/system/caches/git directory to force fresh clones. If you do not want to do a fresh clone, you can stop TeamCity and run "git gc" manually for all the <git-XXX> git clones in the directory.


  • java.lang.OutOfMemoryError while fetch repository. Usually occurs when there are large files in the repository. By default, TeamCity runs fetch in a separate process. To increase memory available to this process, change the teamcity.git.fetch.process.max.memory internal property (see description of this property above).
  • Teamcity run as a Windows service cannot access a network mapped drives, so you cannot work with git repositories located on such drives. To make this work, run TeamCity using teamcity-server.bat.
  • inflation using streams in JGit prevents OutOfMemoryError, but can be time-consuming (see the related thread at jgit-dev for details and the TW-14947 issue related to the problem). If you meet conditions similar to those described in the issue, try to increase teamcity.git.stream.file.threshold.mb. Additionally, it is recommended to increase the overall amount of memory dedicated for TeamCity to prevent OutOfMemoryError.