user2296207
user2296207

Reputation: 171

Store git fetch output in a txt file

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

Answers (2)

sehe
sehe

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

Slaven Rezic
Slaven Rezic

Reputation: 4581

The output is written to stderr, not to stdout. So you have to add 2>&1 to the command line.

Upvotes: 9

Related Questions