是否可以使用 reposurgeon 之类的工具将 git 存储库中的 UTF-16 文件的所有提交转换为 UTF-8?
我有一个 git 存储库,其中包含 UTF-16 文件。偶然它只是 UTF-16,该文件可以用 7 位 ascii 编码而不会丢失数据。我想使用类似 reposurgeon 将文件转换为 UTF-8 以便git diff 将适用于文件的旧版本,我不必求助于 git difftool。这可能吗?
I have a git repository that has a UTF-16 file in it. Its only UTF-16 by accident, the file could be encoded in 7-bit ascii without a loss of data. I'd like to use something like reposurgeon to convert the file to UTF-8 so that git diff will work with older revisions of the file and I don't have to resort to git difftool. Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不将文件转换为 UTF-8 并提交它,例如:
在澄清注释后更新:
如果您想在
历史记录中的每次提交时重写该文件HEAD
,您可以使用git filter-branch
,类似于:当然,如果您以这种方式重写历史记录,如果您与任何人共享此存储库,则可能会导致问题。 (我还没有测试该命令 - 小心使用它,可能只是您存储库的新克隆。)
Why don't you just covert the file to UTF-8 and commit it, e.g. with:
Update after a clarifying comment:
If you want to rewrite that file at every commit in the history of
HEAD
, you can usegit filter-branch
, something like:Of course, if you're rewriting history in this way, it may cause problems if you have shared this repository with anyone. (I haven't tested that command - use it with care, probably only a new clone of your repository.)