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

Re: pushing a project started in git back to a subversion repository...

From
Jeff King <peff@peff.net>
Date
Jul 3, 2007, 04:37 UTC
Message-ID
<20070703043733.GC4007@coredump.intra.peff.net>
In-Reply-To
<e2a1d0aa0707021329p29242393ua10817c85ca7422a@mail.gmail.com>
On Mon, Jul 02, 2007 at 04:29:11PM -0400, Patrick Doyle wrote:
Show 10 quoted lines
> Here is what I did:
> 1) packed up the existing git repository with "git-pack-objects"
> [...]
> 2) Used git-rev-list to find the name of first and last commits in my repo.
> [...]
> 3) Cloned the SVN repository, which I had previously created with an
> empty directory into which I wanted to import my new project
> [...]
> 4) unpacked the packfile into the new .git repo
> [...]
That's a bit complex. How about:
  1) clone the svn repository as in your step 3
  2) fetch the old master into a local branch
     git-fetch ../path/to/original master:original
Show 5 quoted lines
> 5) Created a .git/info/grafts file with the first commit from my old
> .git repo grafted onto the single (empty directory) commit of this new
> repo
>
> $ echo XXX YYY > .git/info/grafts

So you are grafting onto a totally uninteresting commit? That seems like a hack to base your commits on something that is "in" git-svn. I suspect there is a way to do it more elegantly, but I've never used git-svn, so I can't comment.

You could of course now do the graft as:
  echo "`git-rev-parse original` `git-rev-parse master`" >.git/info/grafts
> 6) Here's the scary part -- I overwrote .git/refs/heads/master with
> [...]
> 7) Fetched the files into my empy directory
You could also do this (while on the master branch):
  git reset --hard original

which will set master's sha1 to the same as your "original" branch, and update the working tree to have all of the files from that commit (because we used --hard).

At this point you can clean up the original branch:
  git-branch -d original
> **** 2nd question: ****
> How many of you cringed when I said I did this?  If so, why?

I cringed a little. It's actually not all that different than what git-reset does, but git-reset will do nice things like locking and putting an entry in the reflog.

> **** Last question: ****
> What happened to all of those objects I imported from the pack file?
They were placed in the second repository's object database.
> I can still see them in the .git/objects/*/* directories, but they
> don't show up in git-ls-revs.  git-fsck doesn't report any errors.

There is no git-ls-revs. Not sure what you mean here. There are no errors because all of the objects are referenced (by your new master branch).

> I'm also curious what experts would think of my fumbling efforts to
> transfer this git-managed project into a git/svn-managed project,
> maintaining the initial history.  Did I go tremendously out of my way
> to do something that was a one-line command?
More or less. ;)

Presumably you could take your _existing_ repository, point it at your svn upstream (look in the .git/config of your svn-cloned repo, and there is presumably some svn config), and do the dcommit. Unfortunately, I have the privilege of never having used svn or git-svn, so I can't comment further.

-Peff
Previous: Patrick DoyleNext: Patrick Doyle
Message 2 of 3 in “pushing a project started in git back to a subversion repository...”
  1. Patrick DoyleJul 2, 2007
  2. Jeff KingJul 3, 2007
  3. Patrick DoyleJul 3, 2007

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.