> For the complete documentation index, see [llms.txt](https://docs.vectice.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.vectice.com/25.2/log-and-manage-assets-with-vectice-api/log-assets-to-vectice/log-code.md).

# Log code

Vectice logs your `git` commit information, including the repository name, branch name, commit hash, and the commit URL when there is a `.git` folder or repository available. **Only** locally changed files not logged in Vectice are logged with each **new** git commit.

{% hint style="info" %}
Vectice is **not** a substitute for a code versioning system and is best used in coordination with a git-based system.
{% endhint %}

## Prerequisites

To log code in Vectice, you will need the following prerequisites:

* Ensure you have [installed vectice](/25.2/log-and-manage-assets-with-vectice-api/connect-to-api.md#install-vectice) with the correct version
* Configure your API to [connect to the Vectice API](/25.2/log-and-manage-assets-with-vectice-api/connect-to-api.md)
* Locally configure your Git username and user email
* Check out a git branch
* Add a valid remote (origin)
* Make at least one commit

### Git configuration

{% hint style="info" %}
Vectice supports all `git` integrations, including **GitHub**, **GitLab**, and **Bitbucket**.
{% endhint %}

You can obtain the prerequisites by first configuring your environment with your `Git` user name and email via the `Git CLI`.

```bash
git config --global user.name "My Name"
git config --global user.email "my@email.com"
```

Then, either clone your existing remote repository or create a new one, followed by adding a valid remote origin.

```bash
git clone https://github.com/user/repo # Clone repo 
```

```bash
git init . # New repo
git remote add origin https://github.com/user/repo # Adding a valid remote origin
```

Lastly, make your first commit to begin code capture.

```bash
git add "README.md" # or some other file
git commit -m "Initial commit"
```

{% hint style="info" %}
Commits may not include the latest code changes in the Vectice app. Ensure to commit all new code changes.
{% endhint %}

## Code capture overview

**Automatic code capture is enabled by default,** and it happens when:

* You push a new commit with code changes that are not already logged
* You [log a model ](/25.2/log-and-manage-assets-with-vectice-api/log-assets-to-vectice/log-models.md)within an iteration
* You [log a dataset](/25.2/log-and-manage-assets-with-vectice-api/log-assets-to-vectice/log-datasets.md) (origin, cleaned, or modeling datasets) within an iteration

{% hint style="info" %}
More than one capture can happen within a single iteration.
{% endhint %}

With automatic code capture **enabled**, you will see the following **log output** indicating successful code capture:

```bash
Code captured the following changed files; <filename>.txt, <anotherfilename>.txt
```

In the Vectice app, you can view the `git` branch and the commit hash. You can click the `git` hash or **View** to see your code changes in your repository.

<figure><img src="/files/os4swssm0xMNWWZW5415" alt=""><figcaption></figcaption></figure>

## Disable code capture

To **disable** the automatic capture of your local code, you can set `code_capture` to `False`, as shown below. Ensure to set this method at the **global** level.

<pre class="language-python"><code class="lang-python"><strong>import vectice
</strong><strong>vectice.code_capture = False
</strong></code></pre>

## Code capture best practices

* Don't forget to **commit your code before running your iteration** so that you log a clean commit into Vectice.
* Work in a separate branch for each experiment to make it easy to reproduce the work and track changes.
* Ensure to **commit your final code changes before completing an iteration** to ensure all the latest commits are logged in the Vectice app.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.vectice.com/25.2/log-and-manage-assets-with-vectice-api/log-assets-to-vectice/log-code.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
