Thursday, 5 March 2015

Why can’t I output the result of git log from a PowerShell script?

Git log is a special command, it uses a pager and it seems the PowerShell ISE hangs when you run into that kind of commands. If you try creating a script relying on running git log in whatever form, you won’t get anything.

The workaround is not the very best, but it does the trick:

$logcommand = "git --no-pager log ... [> file.ext if needed]"
Invoke-Expression $log

Other commands like git diff are not affected by this. This made me lose quite a bit of time this morning…but I am happy to be unblocked now.

No comments:

Post a Comment