什么会导致git搞乱字符编码? [英] What can cause git to mess with character encoding?
问题描述
git不会弄乱字符编码.仍然在这里分享知识,避免其他人犯同样的错误.
git does not mess with character encoding. This is still here to share knowlege and avoid others making the same mistake.
上下文:我的企业使用svn存储库.我使用git-svn作为客户端与此存储库进行交互.项目中的所有文本文件都(并且必须)使用Windows默认编码(cp -....)进行编码.我使用git-extensions,有时使用命令行来试用git.
The context: My enterprise uses an svn repository. I'm using git-svn as a client to interact with this repository. All text files in the project are (and must be) encoded with windows default encoding (cp-....). I use git-extensions, and sometimes the command line to pilot git.
我所做的:在过去三天中,我正在开发一项新功能,并且进行了许多本地提交.最终,我使用交互式rebase将所有这些提交压缩为一个提交,然后使用git svn dcommit在单个提交中将svn存储库中的所有内容推送.
What I did: During the last 3 days, I was working on a new feature, and I did a number of local commits. Finally i squashed all these commits into a single one using an interactive rebase, then i used git svn dcommit to push everything on the svn repository in a single commit.
随后发生的事情:一位同事告诉我,所有口音都被我修改的文件和提交后的新文件弄乱了.之前,我已经在安装git + svn的同一个存储库中提交了带有重音符号的文本文件,这是我第一次遇到此问题.
What happened then: A collegue told me that all accents were messed up in the files that I modified, and in the new files after my commit. I had already commited text files with accents in the same repository with my installation of git + svn before, and it's the first time I face this issue.
我的调查:我做了以下调查:使用notepad ++打开文件,并尝试使用最新的编码(包括Windows默认和UTF-8)查看它们:没有一个正确显示重音符号,并且始终由相同的奇怪字形序列呈现不同的重音符号.
My investigation:I did the following things to investigate: opened the files with notepad++, and tried the most current encodings (including windows default and UTF-8) to view them: none of them could display accents properly, and different accents are always rendered by the same sequence of strange glyphs.
临时解决方法:我迅速创建了一个带有git扩展名的还原提交,并将其取消提交".
The temporary workaround:I quickly created a revert commit with git extension and "dcommited" it.
问题:我的企业svn存储库还可以,但是现在我要解决以下两个问题:
The question:My enterprise svn repository is OK, but now i have the two following problems to solve:
- 了解带有重音符号的字符
- 从SVN历史记录中检索我的作品并以适当的方式提交(如果可能的话,无需手动检查所有带有重音符号的字符)
任何人都可以提供一些线索(我是git的新手)吗?
Can anybody provide some clues (i'm rather new to git) ?
推荐答案
现在让我们来揭示一个痛苦的事实(对我的自我痛苦,而不是git用户痛苦): 我确实弄错了口音,而不是git.
And now let's reveal the painful truth (painful for my ego, not for git users): I did mess with the accents, not git.
我本来可以解决一个问题,那就是我们错误地认为git可以弄乱口音,但是考虑到投票的数量,我认为很多人都犯了与我相同的错误,所以我选择回答我自己的问题以建立真相,并可能在相同情况下为人们提供帮助:
I could have just removed the question which let's wrongly think that git can mess up with accents, but considering the number of upvotes, i think than a lot of people do the same mistake that i did, so I have chosen to answer my own question to establish the truth, and maybe help people in the same case:
- Git除了换行符外不会触摸其他字符.
- 我在提交之前打破了 的口音,但我没有注意到它,因为我没有给予足够的重视.为此,我用Eclipse编辑了一些文件.Eclipse无法识别编码,并且在保存时所有重音都被一个怪异的字节序列代替.就是这样.
- Git does not touch to characters other than line breaks.
- I broke the accents before commiting, and i did not noticed it because i did not pay enough attention. To do so, i edited some of the files with eclipse. Eclipse did not recognize the encoding and the accents were all replace by a weird byte sequence on save. That's all.
再次感谢 Dmitry Pavlenko 为我提供了如何调查此问题的指示.
Thanks again to Dmitry Pavlenko for giving me indications on how to investigate this problem.
+1到"git reflog"
+1 to "git reflog"
固定口音很愉快; =)
Happy accent fixing ;=)
这篇关于什么会导致git搞乱字符编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!