相关疑难解决方法(0)

如何丢弃Git中的未分级更改?

如何放弃工作副本中不在索引中的更改?

git version-control

4562
推荐指数
38
解决办法
242万
查看次数

尝试使用git filter-branch修复行结尾,但没有运气

我被git用Windows/Linux行结束问题所困扰.看来,通过GitHub,MSysGit和其他来源,最好的解决方案是让你的本地存储库设置为使用linux风格的行结尾,但设置core.autocrlftrue.不幸的是,我没有及早做到这一点,所以现在每次我进行更改时,行结尾都会被剔除.

我以为我在这里找到了答案,但我无法让它为我工作.我的Linux命令行知识充其量是有限的,所以我甚至不确定"xargs fromdos"行在他的脚本中做了什么.我不断收到关于没有这样的文件或目录的消息,当我设法将它指向现有目录时,它告诉我我没有权限.

我在Windows上通过Mac OS X终端尝试使用MSysGit.

git newline line-endings msysgit

266
推荐指数
3
解决办法
6万
查看次数

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万
查看次数

似乎无法放弃Git的变化

从命令行看到以下内容后:

# On branch RB_3.0.10
# 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:   index.htm
Run Code Online (Sandbox Code Playgroud)

我试图通过键入命令来放弃我的更改:

git checkout -- index.htm
Run Code Online (Sandbox Code Playgroud)

但是当我重新运行git status时,它看起来完全一样.结帐似乎不起作用.难道我做错了什么?我在windows/cygwin上使用GIT 1.6.1.2.

# On branch RB_3.0.10
# 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: …
Run Code Online (Sandbox Code Playgroud)

git revert

115
推荐指数
7
解决办法
5万
查看次数