Reputation: 171
I want to store the output of this command in a text file and this was my attempt:
git fetch -v --dry-run >test.txt
All what happens is it continues to write to the console and creates an empty txt file. On a high level, I am writing a batch file to determine if there are changes to update my local copy of the repository.
Upvotes: 4
Views: 4452
Reputation: 393009
git fetch -v --dry-run >test.txt 2>&1
or, my preferred method:
git fetch -v --dry-run |& tee test.txt
The |&
requires a recent bash
Upvotes: 4
Reputation: 4581
The output is written to stderr, not to stdout. So you have to add 2>&1
to the command line.
Upvotes: 9