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

Re: git svn dcommit sends to wrong branch

From
Thomas Rast <trast@student.ethz.ch>
Date
Jan 10, 2012, 19:43 UTC
Message-ID
<87ty438ht3.fsf@thomas.inf.ethz.ch>
In-Reply-To
<20120110161843.GC8196@victor>
Victor Engmark <victor.engmark@terreactive.ch> writes:
Show 5 quoted lines
> Commands:
>
> git svn clone -s -r 1:HEAD http://svn/repo
> cd repo
> git commit [thrice, in master only]

Which git version is this? Before 1.6.5 (b186a261 to be precise) git-svn pointed master at the branch where the last commit in SVN happened, which is not necessarily trunk. After that it tries to point it at trunk instead. You can find out, e.g., by saying 'git show' on the fresh clone and looking at the git-svn-id line.

Show 10 quoted lines
> git rebase --interactive HEAD~20 [i.e., started rebase in commits before
> the clone]
> [Merged two commits I had made *after* the clone]
> git commit ...
> git dcommit
>
> This created commits on
> <http://svn/repo/branches/branch_name>! Why? Is it because HEAD~20's
> git-svn-id <http://svn/repo/branches/branch_name@22481> is on that
> branch?

The rule is that the commits go to the branch named in the git-svn-id line of the most recent first-parent ancestor of HEAD.

You can find the "base" commit in question with
  git log -1 --first-parent --grep=^git-svn-id:
> And more importantly, how do I "replay" my commits on trunk?

You need to rebase the commits on trunk, and (very important) strip the git-svn-id lines from their messages. If you only had a handful of commits, your best bet is to use something like

  git checkout -b newbranch
  git rebase -i --onto svn/trunk svn/branch_name  # or whatever git-svn named the remote branches
  # edit all the 'pick' into 'reword'
  # in every commit message editor that pops up, remove the git-svn-id line
  gitk  # make sure that you like the resulting history!
  git svn dcommit

(If you have many commits, git-filter-branch can do the removal automatically, but it's a bit of a loaded gun pointed at your foot.)

If your git-rebase is too old for 'reword', you can use 'edit' instead and then, every time that git-rebase drops you into a command line, say

  git commit --amend   # and edit the commit message
  git rebase --continue
-- 
Thomas Rast
trast@{inf,student}.ethz.ch
Previous: Victor EngmarkNext: Victor Engmark
Message 2 of 5 in “git svn dcommit sends to wrong branch”
  1. Victor EngmarkJan 10, 2012
  2. Thomas RastJan 10, 2012
  3. Victor EngmarkJan 11, 2012
  4. Thomas RastJan 11, 2012
  5. badgerhardyJan 26, 2012

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.