Skip to content

Logging Git info#

If you have Git initialized in your project, Neptune extracts the following information from the .git directory:

  • Dirty: whether the working tree has local changes that have not been committed to the current branch.
  • Commit message: the message of the last commit.
  • Commit ID: Git SHA-1 value of the commit.
  • Commit author: the author of the last commit.
  • Commit date: the date of the last commit.
  • Current branch: the currently checked out Git branch.
  • Remotes: list of Git remotes your local .git is connected to.

The Git data is logged under the source_code/git namespace.

By default, Neptune looks for a repository in the execution path and its parent directories.

Specifying the repository path#

If the repository you want to track is not in the execution path, you can specify a custom path with the repository_path argument of GitRef:

import neptune
from neptune.types import GitRef

run = init_run(git_ref=GitRef(repository_path="/path/to/repo"))
Windows note

To correctly parse a Windows path (C:\Path\to\repo), you need to escape the backslashes.

For example, convert the file path to a raw string:

run = init_run(git_ref=GitRef(repository_path=r"C:\Path\to\repo"))

Disabling Git tracking#

To disable logging of any Git repository information:

import neptune
from neptune.types import GitRef

run = init_run(git_ref=GitRef.DISABLED)