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

rebase -X subtree

From
David A. Greene <greened@obbligato.org>
Date
Dec 1, 2015, 02:22 UTC
Message-ID
<87lh9e9abt.fsf@waller.obbligato.org>
Hi,

I had a particular notion of what rebase -X subtree would do but I am apparently mistaken. What should be the result of the script below? I expected commits to be replayed on top of master with their trees adjusted to move files into a "files" directory. In the first case, the rebase seems to have done nothing. In the second case I get an error:

First, rewinding head to replay your work on top of it... fatal: Could not parse object '6c0826e4cf4b1f44ebafbd4084c1f0066a59d112^' Unknown exit code (128) from command: git-merge-recursive 6c0826e4cf4b1f44ebafbd4084c1f0066a 59d112^ -- HEAD 6c0826e4cf4b1f44ebafbd4084c1f0066a59d112

If "files" exists and I use rebase -X subtree it replays the commits, moving trees out from under "files," as I would expect. Is it not possible to use git rebase to move trees under a new subdirectory?

I know that I can use filter-branch to accomplish what I want, I'm just curious whether git rebase is expected to behave as I thought. At the very least, it seems a better error message in the orphan branch case would be helpful.

Thanks for you help!
                      -David
#!/bin/bash
function addfile {
    name=$1
    echo ${name} > ${name}
    git add ${name}
    git commit -m "Add ${name}"
}

mkdir rebasetest1 cd rebasetest1 git init

addfile README
git checkout -b work
addfile file1
git rebase -X subtree=files --onto master master
cd ..

mkdir rebasetest2 cd rebasetest2 git init

addfile README
git checkout --orphan work
addfile file1
git rebase -X subtree=files --onto master --root
Message 1 of 1 in “rebase -X subtree”
  1. David A. GreeneDec 1, 2015

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.