git config not used when git pull via PHP file

I’m trying to git pull from a PHP file, but it seems like the config isn’t being used.

git config --global and git config --global are set and git pull works from the command line.

  • What are some more forceful ways than a .gitignore to keep (force) files out of a repo?
  • git svn and rebasing a branch rebases master
  • Ruby returning null when printing same string again
  • Problem importing project into git
  • git cherry pick - range of commits and exclude some in between
  • git-diff in another directory
  • Now when I try to execute this script:

    header('Content-type: text/plain');
    system('git pull 2>&1');
    echo "\nCompleted!";

    I get the following output:

    * Please tell me who you are.


    git config –global “” git config
    –global “Your Name”

    to set your account’s default identity. Omit –global to set the
    identity only in this repository.

    fatal: empty ident not allowed


    Is it maybe because the git config is user specfic and PHP is ran from another user?

  • Pull the latest remote git branch incrementally without worrying about merges
  • git config mergetools - tfvc syntax documentation
  • Cannot switch branches
  • Make it as if I had .gitattributes the whole time
  • .gitignore for Visual Studio Projects and Solutions
  • git svn ambiguous argument 'HEAD'
  • 4 Solutions collect form web for “git config not used when git pull via PHP file”

    Just use the -c flag on git itself:

    -c <name>=<value>
    Pass a configuration parameter to the command. The value given will override values from configuration files. The <name> is expected in the same format
    as listed by git config (subkeys separated by dots).

    So something like:

    git -c pull

    should get you there. Add whatever arguments you need. If you want to specify a particular file, then either add the relevant configuration options to the user executing the script, or hack around it by exporting a different HOME env variable first.

    You expect your webserver to work even when you are not logged in, don’t you? This means it is run by another user than you (unless you specified otherwise). Unless you run your script via the CLI, the script is run by apache, www-data or whatever user you configured.

    I managed to get it working, but it’s not an ideal solution. I need to find a way to set the git config for the apache user once, instead of every time. I’m on shared host, so I don’t know if it’s actually possible.

    header('Content-type: text/plain');
    system('git config "Server"');
    system('git config ""');
    system('git pull 2>&1');
    echo "\nCompleted!";

    It’s a bit of kludge, but you can also set the system git config:

    git config --system <user>
    git config --system <user>@<domain>

    This has the rather unfortunate side effect of being the default config for all users of the server, so it really isn’t very good.

    Git Baby is a git and github fan, let's start git clone.