0

问题很简单。Git 说我已将 CR ( ^M) 添加到文件中,

me@myComp MINGW64 /c/workspace/service (develop)
$ git diff --check
engine/src/main/java/someFile.java:18: trailing whitespace.
+import some.java.package;^M

但我已经core.autocrlf设置为true。

me@myComp MINGW64 /c/workspace/service (develop)
$ git config --get core.autocrlf
true

我以前没有遇到过这个问题,也不知道是什么原因造成的。我一直都core.autocrlf设置为 true 并且在此之前从未抱怨过添加^M


这是git config --list删除了一些个人信息、gui 设置和分支设置的输出,以防万一需要。

core.symlinks=false
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
pack.packsizelimit=2g
help.format=html
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
sendemail.smtpserver=/bin/msmtp.exe
diff.astextplain.textconv=astextplain
rebase.autosquash=true
push.default=simple
core.autocrlf=true
core.pager=less -x4
core.trustctime=false
core.editor=vim
core.filemode=false
alias.hist=log --pretty=format:'%ad %C(yellow)%h%C(reset) %s %C(yellow)%an%C(reset)' --date=short
alias.logo=log --oneline
alias.superlog=log --decorate --graph
alias.superlogo=log --decorate --graph --oneline
alias.dry-merge=merge --no-commit --no-ff
gui.recentrepo=C:/sts-workspace/kba-service
merge.tool=vimdiff
merge.conflictstyle=diff3
mergetool.prompt=true
mergetool.keeptemporaries=false
mergetool.keepbackups=false
mergetool.trustexitcode=false
diff.tool=vimdiff
difftool.prompt=true
color.ui=true
credential.helper=cache --timeout=3600
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
core.hidedotfiles=dotGitOnly
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
core.hidedotfiles=dotGitOnly
4

1 回答 1

0

至于为什么突然决定这样做,有两种可能。

  1. 回购的属性文件中的某些特定内容已更改
  2. 那里有一行以 windows 样式行结尾的东西,因此决定默认为该样式。

windows 的配置可能是个婊子,比 linux / mac 更麻烦,但它不是不可管理的。

我将向您展示我自己的配置(win 7 / mingwin),您应该能够轻松搜索我所做的事情。我最初专门花了大约半天的时间研究这个,因为我有点强迫症,所以我可以确定行尾总是在提交时转换为基于 unix(LF)的。

C:\Program Files (x86)\Git\etc\gitconfig
[core]
    autocrlf = false

C:\Program Files (x86)\Git\etc\gitattributes

* text=auto

请注意,您可能应该查看如何配置默认的 git 属性,如果需要,也可以在每个项目的基础上进行设置。我使用这些有用的模板中的网络之一, 但您自己的需求可能会有所不同。


C:\Users\BAXTER\.gitconfig

[core]
    eol = lf

PS这在某种程度上可能是重复的

于 2016-01-11T22:20:32.050 回答