Formatting commit messages

I recently migrated the repository to git from svn. When I look at the log, all commits from SVN are incorrectly formatted in 50/72 format. Is there a way that I can go through each commit message and edit it to fit the git format?

+6
source share
3 answers

You said in a comment:

The repository was moved a week ago and already committed it to Git.

Thus, the best option is to simply live with him and continue to make the correct commit messages from now on.

All methods that modify commit messages in these old commits will modify commits and create completely new objects with different identifiers. Thus, the repositories of everyone who already works with it will be broken, requiring them to manually reset to the new, rewritten state of the repository.

This ends up with much more work (and confusion!) Than is necessary for the trivial issue of committing with an incomplete commit message that was carried over from the old system. I think it’s great to have some kind of long history, from the last days, which does not fit into modern standards. You would not rewrite all commits if you later decided to change the code formatting rules.

+8
source

You will need git filter-branch . This man page is pretty clear.

Use the --msg-filter option, which expects the shell command to receive the original message on stdin and should output the modified message to stdout . Creating a script that will fix your message format is a separate issue =).

If you are going to fix them by hand, just do git rebase -i --root , setting the action to reword . This will go through the whole commit history, opening your text editor for each commit and letting you change the commit message.

+2
source

One option is to edit your commits in svn before importing to git. Use svnadmin dump go to create a human-editable version of the repository, edit the commit messages there (if it were me, I would write a Python script to do this), and then rebuild the repository using svnadmin load

+1
source

Source: https://habr.com/ru/post/946795/


All Articles