-
-
Notifications
You must be signed in to change notification settings - Fork 954
How can I override the home path during Repo() creation due to unsafe repository (REPO is owned by someone else) error #1429
-
I am using git version 2.35.2
. I want to apply following solution How can I specify custom global gitconfig path? due to this error fatal: unsafe repository (REPO is owned by someone else) with ubuntu 20.04
(Related: actions/checkout#760).
HOME=/home/marco/.silly/ git commit -m "silly configuration"
Is it possible to do same work around during Repo
createtion, where I can override the home path?
The way I create my repo in python:
repo = git.Repo(".", search_parent_directories=True)
here could I send HOME
as an env
variable?
Beta Was this translation helpful? Give feedback.
All reactions
It should be possible to change the environment of the python process itself, which should affect spawned commands as well.
I'd be surprised though that changing the home affects that user that git sees when checking it if that is the intend, I could be missing something though.
This article has a few suggestions on how to workaround this issue.
Replies: 2 comments 1 reply
-
It should be possible to change the environment of the python process itself, which should affect spawned commands as well.
I'd be surprised though that changing the home affects that user that git sees when checking it if that is the intend, I could be missing something though.
This article has a few suggestions on how to workaround this issue.
Beta Was this translation helpful? Give feedback.
All reactions
-
@Byron When I run: check_output(["env", f"HOME={home_dir}", "git", "status"])
, I was able to trick git
, I have use solution here: https://stackoverflow.com/a/52227100/2402577. But I am not sure how this could be applied into git.Repo()
call, might os.environ['HOME'] = 'my_path'
be the solution.
Beta Was this translation helpful? Give feedback.
All reactions
-
Article was the solution, where I had to add the safe.path but trick git to add it into .gitconfig
of another user who owns the repo. I had to do:
check_output(["env", f"HOME={home_dir}", "git", "config", "--global", "--add", "safe.directory", path])
which could also be done easily using GitPython
:
os.environ['HOME'] = 'my_path' # this helped
repo.config("--global", "--add", "safe.directory", path)
Beta Was this translation helpful? Give feedback.