Hey. Due to the specifics, Linux is used at work with KOI8-R, all commits in the git repository were implemented in a local encoding. After some time, it was decided to recode the repository in UTF-8. In this article I want to discuss the technology of changing the encoding of an existing git repository, and at the same time correcting some of the errors made in certain commits.encoding header is filled in, which can later be used when requesting comments. If the encoding header encoding empty, git considers it to be UTF-8. [i18n] commitencoding = UTF-8 logoutputencoding = KOI8-R git commit and git commit-tree commands, the second tells the git log , git show , git blame commands to what encoding the text should be re-encoded before outputting to the user. If none of the parameters is specified, git assumes that logoutputencoding is UTF-8, however, if only the first parameter is set, git uses its value for the second one.encoding header does not match the comment encoding, but is equal to the value of the logoutputencoding parameter, git decides that transcoding is not required and displays the comment text as it is, respectively, on machines with a locale encoding as the comment, the content will be displayed correctly, although all the rest will be garbage.encoding header, you can use the following command: git log –pretty=”%h - '%e': %s” git log command here .git filter-branch command. It allows you to consistently repeat all the commits made beforehand processing the files or meta data with various filters.--msg-filter is used to rewrite the text of the commit comment;--env-filter - used if you need to change the environment in which the commit was made (author's name, email address, etc.);--tag-name-filter - used to rewrite text labels.git filter-branch will execute before recording a commit.HEAD as the target and overwrite the tags according to new commits. To do this, you need to add a tag-name filter with the cat : git filter-branch <> --tag-name-filter 'cat' -- --all HEAD i18n.commitencoding directive - it will be written in all the headers received after performing the repository operation. 'iconv -c -s -f KOI8-R -t UTF-8' git filter-branch command takes the following form: git filter-branch --msg-filter 'iconv -c -s -f KOI8-R -t UTF-8' \ --tag-name-filter 'cat' -- --all HEAD git filter-branch --msg-filter 'iconv -c -s -f KOI8-R -t UTF-8' \ --env-filter 'export GIT_AUTHOR_EMAIL="xxx@gmail.com" export GIT_COMMITTER_EMAIL="xxx@gmail.com"' \ --tag-name-filter 'cat' -- --all HEAD git filter-branch command provides very rich functionality for modifying / fixing the git repository. You can read about all of its features here .Source: https://habr.com/ru/post/178069/
All Articles