5

I'm writing a deployment command for my framework's command line tool. It uses git to deploy.

I have a line where I do this:

exec("git push {$remote} {$branch}:{$branch}", $shell_output, $status);

I would like to have the output of the push inside $shell_output, but its not happening (The output just shows up on terminal). I think because git is an external program and therefore creates a new output stream?

I've tried using an output buffer described here to no avail. I'm sure theres something on SO that can answer this, but haven't been able to find it after much digging..

So any help will be much appreciated :)

1 Answer 1

10

git sends its output to STDERR not STDOUT so you will need to redirect that with something like this:

git push REPO --progress 2>&1

or to a file:

git push REPO --progress > /path/to/file 2>&1

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

Comments

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.