I'm creating a simple, single line batch file to run a git log in my preferred format. When I'm in PowerShell, I type:
git log --pretty=format:"%ai%x09%H%x09%s" > commitlog.csv
And it gives me exactly the output I want. It's the commit author's date and time in ISO format, followed by a tab, followed by the full SHA Hash, followed by a tab, followed by the notes/description. It opens in Excel exactly the way I want.
I tried to make a simple batch file to do the exact same thing so I wouldn't have to remember the format string or search the command history (which occasionally gets cleared, anyway). I noted that I had to use a double percent, %% to replace all the percent signs.
In one version of the batch file I have this line:
git log --pretty=format:"%%ai%%x09%%H%%x09%%s" > commitlog.csv
Which I noted echos the command like this:
git log --pretty=format:"%ai%x09%H%x09%s" 1>commitlog.csv
Which has a "1" interjected into it for some reason, but oddly creates a file with the information, just excluding the tabs, so it all runs together. I read that greater than '>' needs to be preceded by a carat, like so '^>'
So, in the next version of the batch file I changed the line to this:
git log --pretty=format:"%%ai%%x09%%H%%x09%%s" ^> commitlog.csv
Which echos the command like this:
git log --pretty=format:"%ai%x09%H%x09%s" > commitlog.csv
Which I've stared at for a long time, many times, and appears to be EXACTLY what I type in PowerShell, and I would expect to get the same result, but instead I get an error message:
fatal: ambiguous argument '>': unknown revision or path not in the
working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
What am I doing wrong?