I recently migrated a repository to git from svn. When I look at the log, all the commits from SVN are not properly formatted in the 50/72 format. Is there a way that I can go through every commit message and edit it so that it conforms to git format?
-
8Don't worry about it. Just move on and do it properly for new commit messages. Source control is supposed to support your workflow, not make it harder. Yes, the commit messages are not correctly formatted. But is that really such a big problem? – Abizern Jun 07 '13 at 16:46
-
4Just by _having_ commit messages you're ahead of the curve. It's pretty common to see just one giant commit with message "migrated from svn" – gcbenison Jun 07 '13 at 17:23
-
2[For those who don't know what "50/72 format" is](http://stackoverflow.com/q/2290016/1324345) – alroc Jun 07 '13 at 18:38
3 Answers
You said in a comment:
The repository was migrated over a week ago and already has commits on it made in Git.
As such, the best option is to simply live with it and keep making correct commit messages from now on.
All methods that would change the commit messages in those old commits would change the commits and create completely new objects with different IDs. As such the repositories of everyone who is already working with it would break, requiring them to manually reset to the new, rewritten state of the repository.
That ends just in a lot more work (and confusion!) than necessary for the trivial matter of commits with a non-perfect commit message which were migrated from an old system. I think it’s perfectly fine to have some old history, from the days before, which does not fit perfectly into the current standards. You wouldn’t rewrite all commits if you later decide to change your code formatting rules either.

- 369,085
- 72
- 557
- 602
You'll need git filter-branch
. It's man page is pretty clear.
Use the --msg-filter
option which expects a shell command that will receive the original message on stdin
and should output modified message to stdout
. Creating a script that will fix your message format is a separate question =).
If you were going to fix them by hands, then simply do git rebase -i --root
, setting action to reword
. This will go through the whole commit history opening your text editor for every commit and letting you change the commit message.

- 13,248
- 2
- 42
- 57
One option is to edit your commits in svn before importing to git. Use svnadmin dump
go generate a human-editable version of the repository, edit the commit messages there (if it were me, I'd write a Python script to do this), and then rebuild the repository with svnadmin load

- 9,991
- 11
- 77
- 112
-
The repository was migrated over a week ago and already has commits on it made in Git. Would I have to re-migrate the repo and then merge them somehow? – EnactSchmenact Jun 07 '13 at 16:42
-
Subversion dumpfiles aren't "human editable". Each revision has a checksum IIRC and if you attempt to edit the raw file, you'll end up breaking the file. `svnadmin setlog` is the appropriate tool to use for changing log messages in a repository (no dumpfile necessary). – alroc Jun 07 '13 at 18:40
-
@alroc There is a Python tool that helps editing dumps called svndumptool. I had a [related question](http://stackoverflow.com/questions/3886515/recalculate-checksum-in-svn-dump-after-manual-changes) about this and wrote a tool to help utilize it. In case you ever run into having to edit svndumps… – poke Jun 07 '13 at 22:29