Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get TeamCity to create the .git directory when cloning a repo for build?

I'm trying to run a custom command in my MSBuild file; it basically runs 'git log -10' and stores that commit info into a text file.

The problem is, when I try to run the build, it errors saying "fatal: Not a git repository". So I checked TeamCity's work directory for my project, and there is no .git directory!

Why doesn't TeamCity create the .git directory when it clones the repository? Is there a way to enable this?

edit: TeamCity version is 7.1.2; I'll try updating to 8.0.1 to see if there is an option available for this.

like image 615
xofz Avatar asked Jul 09 '13 18:07

xofz


People also ask

How do I change to the local directory where I want to clone my repository?

Go to the current directory where you want the cloned directory to be added. To do this, input cd and add your folder location. You can add the folder location by dragging the folder to Git bash. Click on “Clone or download” and copy the URL.

Which command is used to create a .git folder in the existing project directory?

The git init command creates a new Git repository. It can be used to convert an existing, unversioned project to a Git repository or initialize a new, empty repository.

Which command clones a repository into a new directory?

git-clone: clones a repository into a new directory. Usually, the original repository is located on a remote server.


2 Answers

I changed the VCS checkout mode from server to "automatically on agent" and it works now! Thanks to the answer for this question: Using git commands in a TeamCity Build Step.

like image 69
xofz Avatar answered Oct 18 '22 12:10

xofz


It is documented as VCS Checkout Mode: https://confluence.jetbrains.com/display/TCD9/VCS+Checkout+Mode

TeamCity version is 9.x

like image 32
qqli Avatar answered Oct 18 '22 12:10

qqli