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

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

From
PDPatrick Doyle <wpdster@gmail.com>
Date
Jul 2, 2007, 20:29 UTC
Message-ID
<e2a1d0aa0707021329p29242393ua10817c85ca7422a@mail.gmail.com>

Well, I think I've parsed through the documentation and tips enough to finally produce a script that does what I want it to do... and that was: "I started a project, tracking the revisions with git, and I want to track the changes and revisions on our company Subversion server."

Here is what I did:
1) packed up the existing git repository with "git-pack-objects"
$ git-rev-list master | git-pack-objects --revs --stdout > ../mypack
2) Used git-rev-list to find the name of first and last commits in my repo.

*** 1st question: **** I can use

$ git-rev-list -n 1 master

to get the most recent commit. Is there a similar shortcut to get the very first commit? (I used used "tail -1" to get the last line out of git-rev-list

3) Cloned the SVN repository, which I had previously created with an
empty directory into which I wanted to import my new project
$ git-svn clone url://path/to/repo/topdir
4) unpacked the packfile into the new .git repo

$ cd topdir $ git-unpack-objects < ../mypack

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
6) Here's the scary part -- I overwrote .git/refs/heads/master with
the last commit from my old repo, so now "master" points to a chain of
commits going back to the beginning of time in the old repo and now
grafted onto the empty directory commit of my new repo.

**** 2nd question: **** How many of you cringed when I said I did this? If so, why?

7) Fetched the files into my empy directory
$ git checkout
8) And committed them back to the SVN repo:
$ git-svn dcommit

**** Last question: **** What happened to all of those objects I imported from the pack file? 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. git-gc seems like it packs them up -- I get 193 objects packed into the pack file compared to 167 in a fresh clone of the (newly updated) svn reposistory

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?

--wpd
Next: Jeff King
Message 1 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.