相关疑难解决方法(0)

git status显示修改,git checkout - <file>不会删除它们

我想删除对我的工作副本的所有更改.
运行git status显示修改的文件.
我没做什么似乎删除了这些修改.
例如:

rbellamy@PROMETHEUS /d/Development/rhino-etl (master)
$ git status
# On branch master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   Rhino.Etl.Core/Enumerables/CachingEnumerable.cs
#       modified:   Rhino.Etl.Core/Pipelines/SingleThreadedPipelineExecuter.cs
#       modified:   Rhino.Etl.Tests/Rhino.Etl.Tests.csproj
#       modified:   Rhino.Etl.Tests/SingleThreadedPipelineExecuterTest.cs
#
no changes added to commit (use "git add" and/or "git commit -a")

rbellamy@PROMETHEUS /d/Development/rhino-etl (master)
$ git checkout -- Rhino.Etl.Core/Enumerables/CachingEnumerable.cs

rbellamy@PROMETHEUS …
Run Code Online (Sandbox Code Playgroud)

git revert working-copy git-status

213
推荐指数
9
解决办法
10万
查看次数

行结束转换如何在不同操作系统之间与git core.autocrlf一起使用

我在Stack Overflow上阅读了很多不同的问题和答案,以及关于core.autocrlf设置如何工作的git文档.

这是我对以下内容的理解:

Unix和Mac OSX(OSX之前使用CR)客户端使用LF行结尾.
Windows客户端使用CRLF行结尾.

当在客户端上将core.autocrlf设置为true时,git存储库始终以LF行结束格式存储文件,并且客户端(即Windows)在签出/提交时来回转换客户端文件中的行结尾-LF行结尾,无论行结尾文件在客户端上的格式是什么(这与Tim Clem的定义不一致 - 请参阅下面的更新).

这是一个矩阵,试图为带有问号的core.autocrlf的'input'和'false'设置记录相同的内容,我不确定行结束转换行为.

我的问题是:

  1. 问号应该是什么?
  2. 这个矩阵对"非问号"是否正确?

我将从答案中更新问号,因为似乎已形成共识.

                       core.autocrlf value
            true            input              false
----------------------------------------------------------
commit   |  convert           ?                  ?
new      |  to LF      (convert to LF?)   (no conversion?)

commit   |  convert to        ?                 no 
existing |  LF         (convert to LF?)     conversion

checkout |  convert to        ?                 no
existing |  CRLF       (no conversion?)     conversion

我并不是真的在寻找各种设置的利弊意见.我只是在寻找数据,这清楚地说明了如何期望git能够在三种设置中运行.

-

2012年4月17日更新:阅读由JJD在评论中链接的Tim Clem的文章后,我修改了上表中"未知"值中的一些值,并更改了"checkout existing | true to conversion"到CRLF而不是转换为客户".以下是他给出的定义,这些定义比我在其他地方看到的更清楚:

core.autocrlf …

git newline core.autocrlf

208
推荐指数
6
解决办法
10万
查看次数

即使autocrlf设置为false,也会在checkout,reset --hard等之后修改Git文件

这是我的系统对话:

unrollme-dev-dan:views Dan$ git reset --hard HEAD
HEAD is now at 3f225e9 Fix scan titles
unrollme-dev-dan:views Dan$ 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/signup/finish.html
#   modified:   app/signup/scan.html
#
Run Code Online (Sandbox Code Playgroud)

我将autocrlf设置为false:

unrollme-dev-dan:unroll-website Dan$ git config core.autocrlf
unrollme-dev-dan:unroll-website Dan$ 
unrollme-dev-dan:unroll-website Dan$ git config --global core.autocrlf
unrollme-dev-dan:unroll-website Dan$
Run Code Online (Sandbox Code Playgroud)

而且我没有任何.gitattributes文件弄乱了这个:

unrollme-dev-dan:unroll-website Dan$ find …
Run Code Online (Sandbox Code Playgroud)

git newline core.autocrlf

15
推荐指数
1
解决办法
4605
查看次数

无法还原Idea IDE中的更改

我有几个文件显示为已更改.如果我恢复变化没有任何反应.如果我从磁盘中删除它们然后git checkout -- .从控制台运行它们再次显示为已更改.

如何告诉Idea忘记它们?

其他操作(如pull,commit和push)工作正常.

操作系统:Windows 7.

$ git config core.fileMode
false

$ git status
# On branch bugfix/XXXXX
nothing to commit (working directory clean)
Run Code Online (Sandbox Code Playgroud)

git intellij-idea

4
推荐指数
1
解决办法
1530
查看次数