Skip to content

uv init fails to create .git directory or .gitignore file when inside git repo #11655

Description

@mason-fabel

Summary

When inside of a git repo, running uv init my-project --vsc=git does not create a .git directory or .gitignore file in my-project.

For example, my $HOME is a git repo containing my dotfiles, and I'm trying to create an uv project at $HOME/dev/my-project.

Output

$ uv init my-project --vcs=git --verbose
DEBUG uv 0.6.2
DEBUG Checking for Python environment at `my-project/.venv`
DEBUG Searching for default Python interpreter in managed installations or search path
DEBUG Searching for managed installations at `/home/username/.local/share/uv/python`
DEBUG Found `cpython-3.13.0-linux-x86_64-gnu` at `/usr/bin/python` (first executable in the search path)
DEBUG Writing python versions to `/home/username/dev/my-project/.python-version`
$ rm -rf my-project
$ uv init my-project --verbose
DEBUG uv 0.6.2
DEBUG Checking for Python environment at `my-project/.venv`
DEBUG Searching for default Python interpreter in managed installations or search path
DEBUG Searching for managed installations at `/home/username/.local/share/uv/python`
DEBUG Found `cpython-3.13.0-linux-x86_64-gnu` at `/usr/bin/python` (first executable in the search path)
DEBUG Detected existing version control system: git
DEBUG Writing python versions to `/home/username/dev/my-project/.python-version`
Initialized project `my-project` at `/home/username/dev/my-project`

Example

git init
uv init my-project --vcs=git
cd my-project

# Expected: default uv .gitignore file
# Result: cat: .gitignore: No such file or directory
cat .gitignore

# Expected: new .git directory
# Result: ls: cannot access '.git': No such file or directory
ls .git

Platform

Fedora Linux 41 (Sway) - Linux 6.12.4-200.fc41.x86_64 x86_64 GNU/Linux

Version

uv 0.6.2

Python version

Python 3.13.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions