Skip to content
Advertisement

Execute GIT command from PHP and get error message back

When I try to execute something legitimate – it works, like

JavaScript

returns me a list of available tags.

But when I do something that should return error, like

JavaScript

it returns me NULL, but not message fatal: could not create work tree dir ''.: No such file or directory that I would see in the console.

How can I run a command and get error message from PHP?

UPD: It is not question “how to clone repo with using PHP”, it is “How to retreive error message if something goes wrong” Does not matter what, in my example – “broken” repository link.

Advertisement

Answer

Try this

JavaScript

And then test

JavaScript

This will give you what you want

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement