1

I have here a rather special case: I have some old repositories in different VCSs (git,svn). I now want/have to tidy up things a bit.

The goal was to migrate everything to one single VCS and we decided on git. In a first step I imported the "foreign" VCS history into git using git svn. Everything ok so far.

Another issue was that the users did not use SVN correctly in the sense that all files (including the generated/compiled ones) were added to the VCS. As a result the history is quite large and cumbersome. As new projects will soon start from the actual version I search for a solution to avoid the whole binary data to be kept within every development repo in git. On the oter hand I do not want to throw everything old away. It might be needed in future. as there are severar branches,...

I found the information that the linux kernel used a spliting of the history too (see this question on stackoverflow). I played a bit around with the linux kernel repos to see how things work out there.

Now I am unsure if I understood everything correctly and if I am doing it the right way. Normally I would create an orphaned branch from the working copy and use this one as the starting point of any future development:

git checkout --orphan new_master
<Commit all source files and leave all bin files out>
git remote add new_origin <...>
git push new_origin new_master:master

In case the old history is needed I need to clone the newly created repository as well as the "historical" one. The I have two independent working lines in git which are logically linked.I then add a graft for the initial commit of the new repo to the final commit of the historical repo and should be set up with a complete repo.

Am I correct or is there a better way?

Community
  • 1
  • 1
Christian Wolf
  • 1,187
  • 1
  • 12
  • 33

1 Answers1

2

You can simply use something like

git init
git add .
git commit -m "Import project blablabla"

in a directory containing all the files you want to import (but not the directories like .svn), and get a new Git repository without history.

git checkout --orphan would also work if you already have an imported history and if the latest commit of this history contains the right files.

Then, you want to graft this commit on top of the imported history. Graft points were initially created for this use-case, but they were superseded by git replace. The manual page for git replace is hard to read, but there's a Replace Kicker tutorial.

Matthieu Moy
  • 15,151
  • 5
  • 38
  • 65