2014-03-19 52 views
8

当我在git中的分支之间切换时,即使没有更新,我也会看到文件被更改。这最近刚刚开始发生。在git中更改分支导致更改文件

$ git status 
# On branch dev 
nothing to commit (working directory clean) 


$ git checkout master 
Switched to branch 'master' 


$ git status 
# On branch 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: App.Core/ViewModels/CriteriaViewModel.cs 
#  modified: App.Core/ViewModels/UserManagement/AccountTagsViewModel.cs 
#  modified: App.Core/ViewModels/UserManagement/TagViewModel.cs 
# 
no changes added to commit (use "git add" and/or "git commit -a") 

这些文件,我在Dev分支改变,但加入并提交。任何关于我在做什么的想法都会导致这种情况?

+0

这特别奇怪,因为除非您的更改被提交或隐藏,否则您不能切换分支。切换到'master'后没有任何事情发生? –

+0

@TimCastelijns - 我没有意识到。 – Joe

+0

你可以关闭VisualStudio,执行''git clean -f -x -d''并重复切换吗? –

回答

4

您可以检查这些“更改”文件中的差异是否在eol(行尾)字符中。

如果是,请确保您的core.autocrlf设置为false:

git config core.autocrlf false 

这将避免在结账任何自动转换。

有关更多信息,请参阅“git replacing LF with CRLF”。

如果您需要强制实施一致的eol,请使用.gitattributes指令,如“Fixing the line-endings in a Git repository using the .gitattributes file”中所述。

+1

标记为答案。它似乎修复了它。谢谢! – Joe