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

RFC: new git-transplant subcommand for non-interactively moving commits between branches

From
Adam Spiers <git@adamspiers.org>
Date
May 30, 2016, 00:34 UTC
Message-ID
<20160530003448.GF11256@pacific.linksys.moosehall>
In-Reply-To
<20160527140811.GB11256@pacific.linksys.moosehall>
On Fri, May 27, 2016 at 03:08:11PM +0100, Adam Spiers wrote:
> Hi all,
>
> I finally got around to implementing a new git subcommand which I've
> wanted for quite a while.  I've called it git-splice.
[snipped]
Show 12 quoted lines
> Next steps, and the future
> --------------------------
>
> Obviously, I'd welcome thoughts on whether it would make sense to
> include this in the git distribution.
>
> In the longer term however, I'd like to write two more subcommands:
>
>   - git-transplant(1) which wraps around git-splice(1) and enables
>     easy non-interactive transplanting of a range of commits from
>     one branch to another.  This should be pretty straightforward
>     to implement.

I've now written git-transplant too (and in the process of doing so, made many more enhancements to git-splice).

Usage -----

Examples:
    # Move commits A..B from the current branch onto branch X
    git transplant A..B X
    # Move commits A..B from the current branch into branch X after commit C
    git transplant --after=C A..B X
    # Create a new branch X starting at ref Y, then
    # move commits A..B from the current branch onto X
    git transplant --new-from=Y C A..B X
    # Abort a transplant which failed during cherry-pick or rebase
    git transplant --abort
    # Resume a transplant after manually fixing conflicts caused by
    # cherry-pick or rebase
    git transplant --continue

N.B. this command rewrites history, since after splicing the commits into the target branch, it removes them from the current branch. As with git rebase, you should be aware of all the implications of history rewriting before using it.

Motivation ----------

See the rest of this mail thread.

Code ----

Show 6 quoted lines
> Currently this is in alpha state:
>
>   https://github.com/git/git/compare/master...aspiers:splice
>
> and I reserve the right to rewrite the history of that branch in the
> near future ;-)

This still holds for git-splice, but also now for git-transplant too: the same branch now contains git-transplant and its test suite.

Next steps ----------

- Wait for feedback.  (Ideally I hope people will actually try both tools.)
- If there is any appetite for eventually moving this into the
  distribution, it will still need quite a few things cleaning up first,
  e.g. making the coding style consistent with git's, getting rid of
  bashisms ...
- (Eventually) write git-explode, as explained elsewhere in this thread.

Cheers! Adam

Previous: Adam Spiers
Message 6 of 6 in “RFC: new git-splice subcommand for non-interactive branch splicing”
  1. Adam SpiersMay 27, 2016
  2. Johannes SchindelinMay 27, 2016
  3. Adam SpiersMay 27, 2016
  4. Johannes SchindelinMay 28, 2016
  5. Adam SpiersMay 28, 2016
  6. RFC: new git-transplant subcommand for non-interactively moving commits between branchesAdam Spiers, May 30, 2016

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.