A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://stackoverflow.com/questions/79022092/add-safe-directory-with-gitpython below:

python 3.x - Add safe directory with gitpython

How do I run this git command with gitpython(v2.1.*), please ?

git config --global --add safe.directory "some_dir"

Couldn't find in doc. I tried this:

repo = git.Repo.init(some_dir)
config = repo.config_writer()
config.set_value("user", "email", "[email protected]")
config.set_value("user", "name", "truc")
git_cmd = git.cmd.Git(some_dir)
git_cmd.config("--global", "--add", "safe.directory", some_dir)

But I get this error:

'error: could not lock config file /nonexistant/.gitconfig: No such file or directory'

I'm pretty sure this has something to do with user rights, because if I go to some_dir and directly execute the git command.

  1. as my user, it fails,
  2. as root, it works. But in my Python script config.set_value() commands are working fine for my user, so I guess there might be a way to add safe directory too.

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4