Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GIT_DIR is ignored #1977

Open
obeidahmad opened this issue Oct 23, 2024 · 1 comment
Open

GIT_DIR is ignored #1977

obeidahmad opened this issue Oct 23, 2024 · 1 comment

Comments

@obeidahmad
Copy link

obeidahmad commented Oct 23, 2024

Version 3.1.43

Description:

I am trying to create or open a repo while also changing the .git default path to custom name like .custom_git. However, I a meeting an exception.

Example Code

from pathlib import Path

import git

repo_path = Path("my_repo")
custom_git_dir = Path(".custom_git")

os.environ["GIT_DIR"] = str(custom_git_dir)

repo = git.Repo.init(repo_path)

Error

Traceback (most recent call last):
  File "pythonProject\main.py", line 11, in <module>
    repo = git.Repo.init(repo_path)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "pythonProject\.venv\Lib\site-packages\git\repo\base.py", line 1329, in init
    return cls(path, odbt=odbt)
           ^^^^^^^^^^^^^^^^^^^^
  File "pythonProject\.venv\Lib\site-packages\git\repo\base.py", line 289, in __init__
    raise InvalidGitRepositoryError(epath)
git.exc.InvalidGitRepositoryError: pythonProject\temp

The directory .custom_git gets created but the error happens. The same exception is raised when trying git.Repo(repo_path) instead of initialization with .innit(repo_path).

@Byron
Copy link
Member

Byron commented Oct 23, 2024

Thanks for reporting - I wouldn't be surprised if this wasn't implemented at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants