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.
- as my user, it fails,
- 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.