Projects - Create a Git Repository
![](../../__attachments/143696348/enterprise%20-%20badge@500w.png?inst-v=fbc98f0a-f9ae-4d4c-828f-dc0defe966ca)
Create a Git Repository in the Project namespace
Use the CLI to create the GitRepository resource and add a new repository to your Project.
Refer to air-gapped setup instructions, if you are running in air-gapped environment.
Set the
PROJECT_NAMESPACE
environment variable to the name of your project’s namespace:CODEexport PROJECT_NAMESPACE=<project_namespace>
Adapt the URL of your Git repository.
CODEkubectl apply -f - <<EOF apiVersion: source.toolkit.fluxcd.io/v1beta1 kind: GitRepository metadata: name: example-repo namespace: ${PROJECT_NAMESPACE} spec: interval: 1m0s ref: branch: <your-target-branch-name> # e.g., main timeout: 20s url: https://github.com/<example-org>/<example-repo> EOF
Ensure the status of the
GitRepository
signals a ready state:CODEkubectl get gitrepository example-repo -n ${PROJECT_NAMESPACE}
The repository commit also displays the ready state:
NAME URL READY STATUS AGE
example-repo https://github.com/example-org/example-repo True Fetched revision: master/6c54bd1722604bd03d25dcac7a31c44ff4e03c6a 11m
For more information on the GitRepository resource fields and how to make Flux aware of credentials required to access a private Git repository, see the Flux documentation.
Troubleshoot
To troubleshoot issues with adding the GitRepository, review the following logs:
kubectl -n kommander-flux logs -l app=source-controller
[...]
kubectl -n kommander-flux logs -l app=kustomize-controller
[...]
kubectl -n kommander-flux logs -l app=helm-controller
[...]