offthegrass offthegrass - 7 months ago 57
Git Question

Silence git (no errors, no output, don't say a word)

I'm using git to manage some custom packages. If the package is not in the first repo, I want to run a second command that tries another source. I don't need to tell the user that this is happening. The user doesn't need to know git exists.

if ! git clone directory -q
#do something else

git still prints a fatal error in the console even with

So, how do I silence the little git?

Answer Source

Two ways:

git clone directory > /dev/null 2>&1 - older bash


git clone directory &> /dev/null - newer bash (Above version 4 according to the link below)

For more details read about I/O Redirection in Bash. Essentially what you're doing here is redirect both stdout and stderr to /dev/null, which is "nowhere".

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download