shell - How to redirect full output of `git clone` to a file? -


when run git clone usual, see this:

$ git clone https://github.com/bensmithett/webpack-css-example cloning 'webpack-css-example'... remote: counting objects: 179, done. remote: total 179 (delta 0), reused 0 (delta 0), pack-reused 179 receiving objects: 100% (179/179), 24.07 kib | 0 bytes/s, done. resolving deltas: 100% (79/79), done. checking connectivity... done 

however, when try redirect file, see this:

cloning 'webpack-css-example'... 

here tried:

$ git clone https://github.com/bensmithett/webpack-css-example 2>&1 | tee out.log $ cat out.log cloning 'sample-data'... 

i tried in node.js well, , same thing:

const fs = require('fs'); const child = spawn('git clone https://github.com/bensmithett/webpack-css-example'); child.stdout.on('data', function(data){   console.log(string(data)); }); child.stderr.on('data', function(data){   console.log(string(data)); }); // cloning 'webpack-css-example'... 

why remote: etc. stuff not getting piped either stdin/stderr? there way capture output? if not, happening makes output displayed in terminal, yet not being passed through either stdout or stderr?

by default git display cloning progress when standard error stream directed terminal. since you're redirecting pipe, output stream no longer attached terminal. in order capture output, need add --progress parameter force progress status, e.g.

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

see: man git-clone

--progress

progress status reported on standard error stream default when attached terminal, unless -q specified. flag forces progress status if standard error stream not directed terminal.


to force terminal in other way, you'll have preload library force isatty() return true (see: man isatty). function used git across source code.