Reputation: 51189
I have a git repository with about 30 revisions that I want to import into an existing SVN repository. Unfortunately the SVN repository has a bunch of pre-commit hooks requiring certain information in commit messages, certain SVN keywords in certain file types, and so on. None of these are really relevant to to the stuff I'm checking in, or at any rate, they're not as important as keeping the existing revision history.
In a perfect world, I maybe could do something like:
In a somewhat less perfect world, I could get git-svn to somehow prepend skip-pre-commit-checks (? -- I've never used it before), and then I'd at least have all the revision history in there.
Thoughts?
Updated to add: skip-pre-commit-checks isn't actually a thing; I was misled by a specific hack at a particular project.
Upvotes: 2
Views: 1386
Reputation: 66339
You have a few options.
You can use git filter branch to rewrite your commit messages:
If you need to add Acked-by lines to, say, the last 10 commits (none of which is a merge), use this command:
git filter-branch --msg-filter '
cat &&
echo "Acked-by: Bugs Bunny <[email protected]>"
' HEAD~10..HEAD
You can git rebase interactive to rewrite your commit messages by selecting edit mode
git rebase -i HEAD~30
edit f7f3f6d changed my name a bit
edit 310154e updated README formatting and added blame
edit a5f4a0d added cat-file
...
Then
git commit -v --amend
<editor launched, edit commit message>
git rebase --continue
git commit -v --amend
<editor launched, edit commit message>
git rebase --continue
git commit -v --amend
<editor launched, edit commit message>
git rebase --continue
....
You can also use git rebase to squash everthying into one commit limiting your workload
git rebase -i HEAD~30
pick f7f3f6d changed my name a bit
squash 310154e updated README formatting and added blame
squash a5f4a0d added cat-file
...
<editor launched, edit the combined commit message>
If this is something you're likely to need to do regularly, you can use the prepare commit mesg hook to add some consistency to the format of your commit messages.
Note that, unlike git, you can't skip pre-commit hooks in svn (at least not by any built in mechanism) so attempting to do anything like git commit -va --no-verify
will have no effect as the next time you run git svn dcommit
, it'll fail all the same (if there's something to fail for of course).
Upvotes: 5