即使内容相同,Git状态也会显示文件已更改 [英] Git status shows files as changed even though contents are the same
问题描述
我收到了其他人的git checkout,并试图将未分离的更改提交到本地存储库。然而,即使内容完全相同, (如果不是每个)文件都显示为修改。
我已经将 core.fileMode
设置为false,并将 core.autocrlf
设置为false,但未成功。
值得一提的是,我收到的Git回购是使用Windows的人,而我使用的是Linux。
我可以做什么来提交实际的更改?
编辑: git的输出config -l </ strong>
user.name = Aron Rotteveel
user .email = LT;去除>
color.diff = auto
color.status = auto
color.branch = auto
color.interactive = auto
color.ui = true
color .pager = true
color.branch.current =黄色反转
color.branch.local =黄色
color.branch.remote =绿色
color.diff.meta =黄色粗体
color.diff.frag =洋红色粗体
color.diff.old =红色粗体
color.diff.new =绿色粗体
color.status.added =黄色
color.status.changed = green
color.status.untracked = cyan
core.pager = less -FRSX
core.whitespace = fix,-indent-with-non-tab,trailing -space,cr-at-eol
alias.co =结帐
core.repositoryformatversion = 0
core.filemode = false
core.bare = false
核心。 logallrefupdates = true
core.symlinks = false
core.ignorecase = true
core.hidedotfiles = dotGitOnly
core.autocrlf = false
remote.origin.url =< ;除去>
remote.origin.fetch = + refs / heads / *:refs / remotes / origin / *
更新:添加一些随机示例文件。这些文件只是明文,所以最容易包括。
原始文件位于: https://gist.github.com/c3c5302430935155ef3d 。 Hexdumps明确指出这些文件是不同的,但我不知道是什么原因造成的,以及如何解决它。
HEAD版本:
0000000:4854 4d4c 2e53 6166 654f 626a 6563 740d HTML.SafeObject。
0000010:0a54 5950 453a 2062 6f6f 6c0d 0a56 4552 .TYPE:bool..VER
0000020:5349 4f4e 3a20 332e 312e 310d 0a44 4546 SION:3.1.1..DEF
0000030:4155 4c54 3a20 6661 6c73 650d 0a2d 2d44 AULT:false ..-- D
0000040:4553 4352 4950 5449 4f4e 2d2d 0d0a 3c70 ESCRIPTION - ..< p
0000050:3e0d 0a20 2020 2057 6865 7468 6572 206f>是否o
0000060:7220 6e6f 7420 746f 2070 6572 6d69 7420 r不允许
0000070:6f62 6a65 6374 2074 6167 7320 696e 2064 d
中的对象标记0000080:6f63 756d 656e 7473 2c20 7769 7468 2061 ocument,with a
0000090:206e 756d 6265 7220 6f66 2065 7874 7261额外
的数目00000a0:0d0a 2020 2020 7365 6375 7269 7479 2066 ..安全f
00000b0:6561 7475 7265 7320 6164 6465 6420 746f添加到
的特征00000c0:2070 7265 7665 6e74 2073 6372 6970 7420防止脚本
00000d0:6578 6563 7574 696f 6e2e 2054 6869 7320执行。这
00000e0:6973 2073 696d 696c 6172 2074 6f0d 0a20类似于...
00000f0:2020 2077 6861 7420 7765 6273 6974 6573什么网站
0000100:206c 696b 6520 4d79 5370 6163 6520 646f如MySpace将
0000110:2074 6f20 6f62 6a65 6374 2074 6167 732e添加到对象标签。
0000120:2020 596f 7520 7368 6f75 6c64 2061 6c73您应该等于
0000130:6f20 656e 6162 6c65 0d0a 2020 2020 254f o启用..%O
0000140:7574 7075 742e 466c 6173 6843 6f6d 7061 utput.FlashCompa
0000150:7420 696e 206f 7264 6572 2074 6f20 6765 t为了ge
0000160:6e65 7261 7465 2049 6e74 6572 6e65 7420 nerate Internet
0000170:4578 706c 6f72 6572 0d0a 2020 2020 636f Explorer .. co
0000180:6d70 6174 6962 696c 6974 7920 636f 6465 mpatibility code
0000190:2066 6f72 2079 6f75 7220 6f62 6a65 6374 for your object
00001a0:2074 6167 732e 0d0a 3c2f 703e 0d0a 2d2d标签...< / p> ..--
00001b0:2320 7669 6d3a 2065 7420 7377 3d34 2073#vim:et sw = 4 s
00001c0:7473 3d34 0d0a ts = 4 ..
复制版本:
0000000:4854 4d4c 2e53 6166 654f 626a 6563 740a HTML.SafeObject。
0000010:5459 5045 3a20 626f 6f6c 0a56 4552 5349类型:bool.VERSI
0000020:4f4e 3a20 332e 312e 310a 4445 4641 554c ON:3.1.1.DEFAUL
0000030:543a 2066 616c 7365 0a2d 2d44 4553 4352 T:false .-- DESCR
0000040:4950 5449 4f4e 2d2d 0a3c 703e 0a20 2020 IPTION - 。< p> ;.
0000050:2057 6865 7468 6572 206f 7220 6e6f 7420是否
0000060:746f 2070 6572 6d69 7420 6f62 6a65 6374允许对象
0000070:2074 6167 7320 696e 2064 6f63 756d 656e tags in文件
0000080:7473 2c20 7769 7468 2061 206e 756d 6265 ts,数量
0000090:7220 6f66 2065 7874 7261 0a20 2020 2073 r额外。 s
00000a0:6563 7572 6974 7920 6665 6174 7572 6573安全特征
00000b0:2061 6464 6564 2074 6f20 7072 6576 656e加入预防
00000c0:7420 7363 7269 7074 2065 7865 6375 7469 t脚本执行
00000d0:6f6e 2e20 5468 6973 2069 7320 7369 6d69。这是类似于
00000e0:6c61 7220 746f 0a20 2020 2077 6861 7420 lar to。什么
00000f0:7765 6273 6974 6573 206c 696b 6520 4d79像My
这样的网站0000100:5370 6163 6520 646f 2074 6f20 6f62 6a65空间做到目标
0000110:6374 2074 6167 732e 2020 596f 7520 7368 ct标签。 You sh
0000120:6f75 6c64 2061 6c73 6f20 656e 6162 6c65也可启用
0000130:0a20 2020 2025 4f75 7470 7574 2e46 6c61。 %Output.Fla
0000140:7368 436f 6d70 6174 2069 6e20 6f72 6465 shCompat in orde
0000150:7220 746f 2067 656e 6572 6174 6520 496e r产生In
0000160:7465 726e 6574 2045 7870 6c6f 7265 720a ternet资源管理器。
0000170:2020 2020 636f 6d70 6174 6962 696c 6974兼容
0000180:7920 636f 6465 2066 6f72 2079 6f75 7220 y代码为您的
0000190:6f62 6a65 6374 2074 6167 732e 0a3c 2f70物件标签。 。< / p
00001a0:3e0a 2d2d 2320 7669 6d3a 2065 7420 7377> .--#vim:et sw
00001b0:3d34 2073 7473 3d34 0a = 4 sts = 4。
更新:问题已经解决:
这很简单:第一个文件具有CRLF行结束符(windows),第二个
LF(Unix)。文件
util(可在git \usr\bin中找到)会告诉你(file ab
)会回复
类似于a:ASCII文本,带有CRLF行结束符b:ASCII
)
text
下面的原始答案: 不是显示一个不同的行。你可以发布.git / config(或更好的 您可能会忽略一些空格忽略激活您应该尝试禁用 也是 可用于验证文件实际上是不同的。使用外部差异也可以工作 I received a git checkout from someone else and am trying to commit the unstaged changes to the local repository. However, a lot (if not every) file appears as modified even though the contents are exactly the same. I already set Worth mentioning is that the Git repo I received was from someone using Windows, while I use Linux. What can I do to commit the actual changes? EDIT: output of Update: added some random example files. These files are just plaintext, so are the easiest to include. Original files are located here: https://gist.github.com/c3c5302430935155ef3d. Hexdumps definately indicate that the files are different, but I have no clue what causes this, and how to fix it. HEAD version: Copied version:
Update: as per the comment on this question, the problem has been solved: That is easy: the first file has CRLF line-ends (windows), the second
LF (Unix). The Original answer below: The diff you show does not show a single different line. Can you post .git/config (or better You might have some whitespace ignores activated You should try to disable also could be used to verify that the files are in fact different. Using external diff could work as well
这篇关于即使内容相同,Git状态也会显示文件已更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
git config -l </ code>)。
核心。空白=固定,齿压与 - 非标签,尾随空间,CR-AT-EOL
;
git show HEAD:myfile | md5sum
md5sum myfile
git show HEAD:myfile> /tmp/myfile.HEAD
diff -u myfile /tmp/myfile.HEAD
#或者如果您喜欢交互式工具,例如:
vim -d myfile /tmp/myfile.HEAD
core.fileMode
to false and also set core.autocrlf
to false, without success.git config -l
:user.name=Aron Rotteveel
user.email=<removed>
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=auto
color.ui=true
color.pager=true
color.branch.current=yellow reverse
color.branch.local=yellow
color.branch.remote=green
color.diff.meta=yellow bold
color.diff.frag=magenta bold
color.diff.old=red bold
color.diff.new=green bold
color.status.added=yellow
color.status.changed=green
color.status.untracked=cyan
core.pager=less -FRSX
core.whitespace=fix,-indent-with-non-tab,trailing-space,cr-at-eol
alias.co=checkout
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
core.hidedotfiles=dotGitOnly
core.autocrlf=false
remote.origin.url=<removed>
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
0000000: 4854 4d4c 2e53 6166 654f 626a 6563 740d HTML.SafeObject.
0000010: 0a54 5950 453a 2062 6f6f 6c0d 0a56 4552 .TYPE: bool..VER
0000020: 5349 4f4e 3a20 332e 312e 310d 0a44 4546 SION: 3.1.1..DEF
0000030: 4155 4c54 3a20 6661 6c73 650d 0a2d 2d44 AULT: false..--D
0000040: 4553 4352 4950 5449 4f4e 2d2d 0d0a 3c70 ESCRIPTION--..<p
0000050: 3e0d 0a20 2020 2057 6865 7468 6572 206f >.. Whether o
0000060: 7220 6e6f 7420 746f 2070 6572 6d69 7420 r not to permit
0000070: 6f62 6a65 6374 2074 6167 7320 696e 2064 object tags in d
0000080: 6f63 756d 656e 7473 2c20 7769 7468 2061 ocuments, with a
0000090: 206e 756d 6265 7220 6f66 2065 7874 7261 number of extra
00000a0: 0d0a 2020 2020 7365 6375 7269 7479 2066 .. security f
00000b0: 6561 7475 7265 7320 6164 6465 6420 746f eatures added to
00000c0: 2070 7265 7665 6e74 2073 6372 6970 7420 prevent script
00000d0: 6578 6563 7574 696f 6e2e 2054 6869 7320 execution. This
00000e0: 6973 2073 696d 696c 6172 2074 6f0d 0a20 is similar to..
00000f0: 2020 2077 6861 7420 7765 6273 6974 6573 what websites
0000100: 206c 696b 6520 4d79 5370 6163 6520 646f like MySpace do
0000110: 2074 6f20 6f62 6a65 6374 2074 6167 732e to object tags.
0000120: 2020 596f 7520 7368 6f75 6c64 2061 6c73 You should als
0000130: 6f20 656e 6162 6c65 0d0a 2020 2020 254f o enable.. %O
0000140: 7574 7075 742e 466c 6173 6843 6f6d 7061 utput.FlashCompa
0000150: 7420 696e 206f 7264 6572 2074 6f20 6765 t in order to ge
0000160: 6e65 7261 7465 2049 6e74 6572 6e65 7420 nerate Internet
0000170: 4578 706c 6f72 6572 0d0a 2020 2020 636f Explorer.. co
0000180: 6d70 6174 6962 696c 6974 7920 636f 6465 mpatibility code
0000190: 2066 6f72 2079 6f75 7220 6f62 6a65 6374 for your object
00001a0: 2074 6167 732e 0d0a 3c2f 703e 0d0a 2d2d tags...</p>..--
00001b0: 2320 7669 6d3a 2065 7420 7377 3d34 2073 # vim: et sw=4 s
00001c0: 7473 3d34 0d0a ts=4..
0000000: 4854 4d4c 2e53 6166 654f 626a 6563 740a HTML.SafeObject.
0000010: 5459 5045 3a20 626f 6f6c 0a56 4552 5349 TYPE: bool.VERSI
0000020: 4f4e 3a20 332e 312e 310a 4445 4641 554c ON: 3.1.1.DEFAUL
0000030: 543a 2066 616c 7365 0a2d 2d44 4553 4352 T: false.--DESCR
0000040: 4950 5449 4f4e 2d2d 0a3c 703e 0a20 2020 IPTION--.<p>.
0000050: 2057 6865 7468 6572 206f 7220 6e6f 7420 Whether or not
0000060: 746f 2070 6572 6d69 7420 6f62 6a65 6374 to permit object
0000070: 2074 6167 7320 696e 2064 6f63 756d 656e tags in documen
0000080: 7473 2c20 7769 7468 2061 206e 756d 6265 ts, with a numbe
0000090: 7220 6f66 2065 7874 7261 0a20 2020 2073 r of extra. s
00000a0: 6563 7572 6974 7920 6665 6174 7572 6573 ecurity features
00000b0: 2061 6464 6564 2074 6f20 7072 6576 656e added to preven
00000c0: 7420 7363 7269 7074 2065 7865 6375 7469 t script executi
00000d0: 6f6e 2e20 5468 6973 2069 7320 7369 6d69 on. This is simi
00000e0: 6c61 7220 746f 0a20 2020 2077 6861 7420 lar to. what
00000f0: 7765 6273 6974 6573 206c 696b 6520 4d79 websites like My
0000100: 5370 6163 6520 646f 2074 6f20 6f62 6a65 Space do to obje
0000110: 6374 2074 6167 732e 2020 596f 7520 7368 ct tags. You sh
0000120: 6f75 6c64 2061 6c73 6f20 656e 6162 6c65 ould also enable
0000130: 0a20 2020 2025 4f75 7470 7574 2e46 6c61 . %Output.Fla
0000140: 7368 436f 6d70 6174 2069 6e20 6f72 6465 shCompat in orde
0000150: 7220 746f 2067 656e 6572 6174 6520 496e r to generate In
0000160: 7465 726e 6574 2045 7870 6c6f 7265 720a ternet Explorer.
0000170: 2020 2020 636f 6d70 6174 6962 696c 6974 compatibilit
0000180: 7920 636f 6465 2066 6f72 2079 6f75 7220 y code for your
0000190: 6f62 6a65 6374 2074 6167 732e 0a3c 2f70 object tags..</p
00001a0: 3e0a 2d2d 2320 7669 6d3a 2065 7420 7377 >.--# vim: et sw
00001b0: 3d34 2073 7473 3d34 0a =4 sts=4.
file
util (available in git\usr\bin) will show you that (file a b
will reply
something like a: ASCII text, with CRLF line terminators b: ASCII
text
)
git config -l
). core.whitespace=fix,-indent-with-non-tab,trailing-space,cr-at-eol
; git show HEAD:myfile|md5sum
md5sum myfile
git show HEAD:myfile > /tmp/myfile.HEAD
diff -u myfile /tmp/myfile.HEAD
# or if you prefer an interactive tool like e.g.:
vim -d myfile /tmp/myfile.HEAD