Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to disable use of user and global config? #1212

Unanswered
ssbarnea asked this question in Q&A
Discussion options

I posted the same question on SO https://stackoverflow.com/questions/67109964/how-to-force-gitpython-to-ignore-global-git-configuration but i think it would make sense to repeat it here, being specific to the project.

While I was able to find an ugly workaround for forcing git to ignore its system or user configuration, I was not able to achieve the same while using gitpython.

GIT_CONFIG_NOSYSTEM=1 XDG_CONFIG_HOME=/ HOME=/ git ...

How can I achieve the same using gitpython library?

Note that I tried hacking os.environ but it appears to not work. If anyone wonders why I would want this is just because I want to have a portable is_dirty() implementation, one that does not consider user ignores as I want developer to add required ignores if those are needed.

You must be logged in to vote

Replies: 1 comment

Comment options

More information would be required to answer this as it depends on how you are using GitPython.

In short, if repo.git.command(...) syntax is used that can be affected with environment variables and behave accordingly.

If the built in method is used...

def is_dirty(self, index: bool = True, working_tree: bool = True, untracked_files: bool = False,

...a PR might be required to make it respect environment variables. It might already be possible to affect it by using this context manager though.

def custom_environment(self, **kwargs):
You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /