Skip to content

Git Commit Command Fails (Exit Code 1) #74

@dmerfeld

Description

@dmerfeld

My code structure looks something like this:

use CzProject\GitPhp\Git;

$git = new Git;

$repo = $git->open(base_path());  // base path of local files
$repo->checkout('main');
$repo->pull('origin');

// make some changes to the local files.

// check for changes made
if ($repo->hasChanges()) {
  $repo->addAllChanges();
  $repo->commit('My Commit Message');
  $repo->push(NULL, array('--repo' => 'https://'.env('GITHUB_USER').':'.env('GITHUB_PASS').'@github.com/MyUser/MyRepo.git'));
}

I am able to read the repo, make changes, detect those changes all with success. However when I try to do a commit, I get an error. Command 'git commit -m 'My Commit Message'' failed (exit-code 1).

I've tried setting up the repo to use https and SSH, both fail at the same step. All commands continue to work in the Terminal as expected. Any thoughts on why I would get a failure on the commit command?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions