Problem
I am running some git commands through PowerShell but I am having issues capturing the output.
Many of the ways I have looked into have failed to capture any output at all until I tried using Out-File
. Unfortunately, despite how well this has been working for me, I have found that something is going wrong with the git push
command that is preventing me from capturing the output...
My code looks as follows:
git add . | Out-File $logFilePath -Append
git status . | Out-File $logFilePath -Append
git commit -m "Some Relevant update message" | Out-File $logFilePath -Append
git push origin $branchname | Out-File $logFilePath -Append
When I look at the log files, it shows everything but the output of the git push
. So in troubleshooting this, I removed the | Out-File
from the line and noticed that even the output window was not showing the output of the git push
anymore. It was only when I completely removed the Out-File
from all of the git commands that I was able to get the output to display as expected again. Unfortunately, this put me back at square one.
Question
Does anyone know how to best capture the output of git commands using PowerShell, or can point out what I am doing wrong?