How to capture full output of `git clone`? How to capture full output of `git clone`? unix unix

How to capture full output of `git clone`?


By default Git will display the cloning progress only when the standard error stream is directed to a terminal. Since you're redirecting it to the pipe, the output stream is no longer attached to the terminal. So in order to capture the output, you need to add --progress parameter to force the progress status, e.g.

git clone --progress https://github.com/foo/bar 2> out.log

or, in order to store the output in a shell variable

out=$(git clone --progress https://github.com/foo/bar 2>&1)

See: man git-clone

--progress

Progress status is reported on the standard error stream by default when it is attached to a terminal, unless -q is specified. This flag forces progress status even if the standard error stream is not directed to a terminal.


To force the terminal in any other way, you'll have to preload some library to force isatty() to return always true (see: man isatty). This function is used by git across the source code.