Can git operate in “silent mode”?

Question:

Is it possible to execute any git command in “silent” mode? For instance, can i say “git push origin” and see nothing displayed on the screen?

I suppose i can redirect IO to /dev/null (works fine), but .. does git allow something like this naturally?

Below is a quick script that does automatic EOD commit, used when i need to catch the train and don’t want to leave code on my local computer

Please let me know.

Answer:

Redirecting output to /dev/null seems like a natural way of doing it to me. Although I have in the past defined a quiet_git shell function like this for use in cron jobs:

This will suppress stdout and stderr, unless the git command fails. It’s not pretty; in fact the stdout file is ignored and it should just redirect that to /dev/null. Works, though. And then you can just do “quiet_git push” etc. later on in the script.

Leave a Reply