1

After a lot of searching, I'm about to tear my hair out on this one and solution might even be dead simple but I've just overlooked it...

I'm trying run a shell script from PHP to git add -A and commit everything in the repository when a button on a web UI is clicked.

<? php
$commitMsg = 'foo';
$output = shell_exec('/Applications/MAMP/htdocs/gitlist/bash/gitlist-commit '.$commitMsg);
#!/bin/bash
cd /var/www/html/development
sudo -H -u username git add -A
sudo -H -u username git commit -m $1

It works on my MAMP/OSX setup, but not on my Ubuntu LTS box. What might I have overlooked?

On the server, I get returned, which I'm guessing means that the git add -A command is just not working. Am I right?

It also works when running directly from the terminal, but not when running via the web UI.

On branch master
Changes not staged for commit:
  (use "git add ..." to update what will be committed)
  (use "git checkout -- ..." to discard changes in working directory)

        modified: README.md

no changes added to commit (use "git add" and/or "git commit -a")

Any help would be appreciated.

7
  • you sure the executing user has sudoers? Commented Jan 13, 2015 at 20:04
  • 1
    Re: "on the server i get returned": Did you leave out a few words here? Commented Jan 13, 2015 at 20:06
  • Please use capitalization and punctuation correctly; Stack-Overflow users will be more likely to take the time to read and answer your questions. Commented Jan 13, 2015 at 20:08
  • Run your script with bash -x script_name.sh, maybe you'll spot the error right away. Commented Jan 13, 2015 at 20:13
  • I just mean when I echo $output thats the message I get. @Jubobs can you please tell me what is wrong with my question? It looks like a pretty straight forward question to me. Commented Jan 13, 2015 at 20:25

1 Answer 1

1

try git add .; git add -u as this will accomplish the same thing "adding all files" but is a potential workaround based on your shell setup.

Sign up to request clarification or add additional context in comments.

3 Comments

oh man you are my hero. this worked great, I'd love to know why if you get a moment. Thank you again!
@digital-pollution sure thing [git add -A stages All] [git add . stages new and modified, without deleted] [git add -u stages modified and deleted, without new]
oh thanks I meant, what could it be about my shell setup that requires this workaround I have the same problem with pushing and pulling

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.