Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pipe git clone

I'm trying to improve my CI tooling and to do so I'm trying to capture the output of the git clone command, and this is driving me crazy.

In order to simplify the scenario, I reduce the problem to this simple command:

git clone --progress https://github.com/$REPO.git $FOLDER 2>&1 | xargs echo  -

With 2>&1 I'm redirecting the stderr (use by git to output the progress) to the stdout, then I'm trying to pipe that to xargs echo -. In my real life scenario xargs echo will be replaced by something else.

I'm using --progress in order to force git to be verbose even if it is not attached to a real console.

My expected output would be:

- Cloning into 'a3'...
- remote: Counting objects: 54130, done.
- remote: Compressing objects: 100% (520/520), done.

My output is instead absolutely nothing. I'm testing this on OSX 10.11.

Does anyone know what's wrong with that command?

Thank you very much in advance.

like image 712
Luka Avatar asked Feb 11 '26 09:02

Luka


1 Answers

I solved it by using

git clone --progress --branch $TAG_VERSION https://github.com/$REPO ./ 2>&1 | tr '\u000D' '\n'"
like image 186
Luka Avatar answered Feb 14 '26 00:02

Luka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!