nidHi
nidHi

Reputation: 833

Can't run any git commands in $GERRIT_SITE/git folder

I have gerrit installed.

When a project is created through the gerrit web UI, the project is reflected in the $GERRIT_SITE/git folder.

For instance if a project trial is created on gerrit, a trial.git folder is created in $GERRIT_SITE/git folder.

But when I try to run any git commands in $GERRIT_SITE/git/trial.git folder such as follows, I get the following error:

$ git status
fatal: This operation must be run in a work tree

I do not know how to go about this and would need some guidance.

Upvotes: 1

Views: 87

Answers (1)

StephenKing
StephenKing

Reputation: 37620

The reason for this is that what you find on disk is a bare repository, without a working tree (i.e. the files of a particular branch). This is totally normal for a Git server and you find the same inside the .git/ directory once you cloned the repository.

EDIT You can work on the server side with these bare repos, when you specify the repo's path as the argument for the GIT_DIR environment variable:

GIT_DIR=/var/gerrit/review/git/trial.git/ git log --quiet --pretty=medium

This is esp. helpful when using Gerrit Hooks to do something, when a new change is merged etc.

Upvotes: 2

Related Questions