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

Git rebase --exec cannot run git commands affecting other repos

From
SBSamir Benmendil <me@rmz.io>
Date
Jan 10, 2019, 16:19 UTC
Message-ID
<20190110161904.23fwbrgg7blyx3nj@uh-nuc001>

It is impossible to run git commands affecting a different repo from within a `git rebase --exec` because in that environment the `GIT_DIR` and `GIT_WORK_TREE` variables are set and inherited by any commands run as part of `git rebase --exec`.

A minimal reproduction is shown below:
    git init
    touch file
    git add file
    git commit -m"Commit"
    git rebase --root --exec="git clone . subrepo"

It is a bit convoluted for the sake of being self contained. But any git command in `--exec` acting on a different repo than the one being rebased will fail. See my ticket on CMake [0] for a more real usecase.

As mentioned in the other ticket, unsetting these variables will work around the issue.

    git rebase --root --exec="env -u GIT_DIR -u GIT_WORK_TREE git clone . subrepo"
[0] https://gitlab.kitware.com/cmake/cmake/issues/18778
Regards
Next: Junio C Hamano
Message 1 of 4 in “Git rebase --exec cannot run git commands affecting other repos”
  1. Samir BenmendilJan 10, 2019
  2. Junio C HamanoJan 10, 2019
  3. Samir BenmendilJan 10, 2019
  4. Jeff KingJan 11, 2019

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.