The aim of this page📝 is to note how to silent git in PowerShell.
Context: I am moving my markdown files with a script to and from a
backlog subfolder within a so-called
slog folder — this is where I keep my work notes/to-do list. I do this quite often and don’t want a messy terminal with the lengthy git outputs but I need git to stage/commit deleted files and assets (screenshots) because I am using version control to tell me what I need to be working on (new/modified markdown files).
move-to-backloghas only the output — nothing about git!
b 2021-10-07-A-Kinesis-Shard-Count-Analysis.md -b
>>> VERBOSE: Performing the operation "Move File" on target "Item: C:\Users\Admin\2021-10-07-A-Shard-Count-Analysis.md Destination: C:\Users\Admin\_backlog\2021-10-07-A-Shard-Count-Analysis.md".
<!-- GIT EXECUTED - NO OUTPUT - SHELL CLEAN -->
1. *> $null
- git, like many CLIs (console/terminal programs), uses the
stderrstream not just to report errors, but also for status information - basically, anything that's not data.
- there are 7 streams in Powershell
name | number | description
STDIN | 0 | Keyboard input
STDOUT | 1 | Text output
STDERR | 2 | Error text output
WARNING | 3 | Warning output
VERBOSE | 4 | Verbose output
DEBUG | 5 | Debug output
INFO | 6 | Information output (PowerShell 5.0+)
- To suppress output from all 6 output streams, use
*> $nullsuppresses all output streams — while external programs only have 2 (stdout and stderr), applying *>$null to a PowerShell-native command silences all 6 output streams
*stands for all 6 streams
>is a redirect operator sending a specified stream to a file/variable
$nullis null in PowerShell, you are not sending it anywhere
- Of course, as a simpler example — you could silent git just by running
*> $nullafter a git command.
<!-- PUSHING WITHOUT OUTPUT -->
~ master ↑6 +18 ~0 -0
▶ git push *>$null
~ master ≣ +18 ~0 -0