git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Redirecting Checkout Output To Variable And Tee StdErr

From
NRNathan Royce <nroycea+kernel@gmail.com>
Date
Jun 4, 2025, 08:00 UTC
Message-ID
<CALaQ_hoWoovjJHMYz_0f1cE1sqt6upqpivv0qNXLy25vEUuonw@mail.gmail.com>

Assigning the subshell output for a `clone` to a variable, while simultaneously outputting to the user works. With `checkout`, it does not.

This was brought up in IRC #git and #bash, and JAA (most of all) and jast and others have contributed well to this finding. This came about by my need to clone part of texlive (which supposedly would otherwise be 6GB (it was already 700MB @ 8%), when I only needed the source, so I used the great `--filter=blob:none`. (I have been made aware of (in the tug ML) the nice `git svn` feature, but wanted something that'd apply to all git repos I come across.) With this blobless clone, it'll only be like 8MB. My intent is to be able to have the user know progress is happening as git `--progress`es, but also grab the output and act on messages that may come up (like any error, where I act on a string of the error).

Test: $ cloneVar=$(git clone --progress --branch trunk --depth 1 --filter=blob:none --no-checkout -- git://git.texlive.info/texlive 2>&1 | tee /dev/stderr) $ checkoutVar=$(git checkout --progress trunk -- Build/source 2>&1 | tee /dev/stderr)

`GIT_TRACE=1` was also mentioned, and that certainly provides output... And while I saw `fetch` being mentioned in it, I saw no reference to `Build/source` in the output to draw on (in case I could manually use `fetch` itself to only get a subpath (which isn't even looking like it's an option)).

Message 1 of 1 in “Redirecting Checkout Output To Variable And Tee StdErr”
  1. Nathan RoyceJun 4, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.