我正在与一群在不同机器上工作的开发人员合作。我碰巧在Mac上工作,在克隆了我们的任何回购后,我立即看到:
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: SomeDirectory/AnotherDirectory/MoreDirectory/AFile.txt
modified: SomeDirectory/AnotherDirectory/DifferentDirectory/AFile.cs
...
执行git status
之后的另外60个文件的列表。
我已经尝试搞乱各种与配置相关的事情,在运行git conflig -l
后,我看到了:
core.excludesfile=/Users/myname/.gitignore_global
difftool.sourcetree.cmd=opendiff "$LOCAL" "$REMOTE"
difftool.sourcetree.path=
mergetool.sourcetree.cmd=/Applications/SourceTree.app/Contents/Resources/opendiff-w.sh "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED"
mergetool.sourcetree.trustexitcode=true
user.name=My Name
user.email=myemail@email.com
filter.lfs.clean=git-lfs clean %f
filter.lfs.smudge=git-lfs smudge %f
filter.lfs.required=true
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=false
remote.origin.url=https://github.com/MyCompany/RepoName.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
我已经尝试了git reset --hard
/ git clean -f -d
,即使只是手动对每个git checkout -- <file>
进行操作,似乎也没有让这些“已修改”的文件消失。
运行git diff
时,我看到每个文件都有以下内容:
The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in SomeDirectory/AnotherDirectory/DifferentDirectory/AFile.cs.
我该如何解决这个问题?
答案 0 :(得分:1)
将true
设置为<LF>
会导致文件结尾在您签出时从<CRLF>
转换为<LF>
。由于您使用的是使用.gitattributes
的Mac,因此您可能不需要该设置。从您看到的行为来看,您的<LF>
文件中可能有设置处理<CRLF>
/ core.autocrlf
翻译的设置,因此请尝试将false
设置为{{ 1}},再次检查项目,看看是否能解决您的问题。