1

I am trying to perform a git pull operation when a django view is called inside the view.

cmd = 'cd %s && git pull origin master' % dir_path
process = subprocess.Popen(cmd, stdout=subprocess.PIPE,
                           stderr=subprocess.PIPE, shell=True)
stdout, stderr = process.communicate()

I get below error in stderr:

fatal: unsafe repository ('/home/user/my_dir' is owned by someone else) To add an exception for this directory, call: git config --global --add safe.directory /home/user/my_dir

I believe it is ownership related issue but not sure about the solution. Command runs just fine when I run it from shell. It is currently running from django runserver.

I have tried adding this directory to safe.directories

git config --global --add safe.directory /home/user/my_dir

but still see the same error

MohitC
  • 4,541
  • 2
  • 34
  • 55
  • 1
    You'll need to configure *django's* `--global` Git configuration so that *django's* Git commands believe that this directory is safe for *django* to use. You've told your Git software that it's safe for *you* to use. – torek May 25 '22 at 06:28

0 Answers0