奇怪的Git行为:神秘的变化无法撤消 [英] Strange behaviour of Git: mysterious changes cannot be undone

查看:565
本文介绍了奇怪的Git行为:神秘的变化无法撤消的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到Git中的一个行为,这对我来说似乎很神秘。
我从 Github 保留Linux存储库的一个克隆,以便在本地使用Git。清楚的是,我在这个仓库中没有做太多工作:我获取更改,更新 master ,签出一个特定的版本,有时我尝试使用Git GUI来查看可视化看起来像一个大项目。
TLDR版本:我从未对其中的文件进行任何更改

今天早些时候,我检出了 master 并从Github中提取了更改。一切似乎都很好。但我怀疑它实际上没有。这就是 git status 现在的样子。

  axel @ macbook〜 / Depot / linux $ git status 
#在分支master上
#没有为commit提交更改:
#(使用git add< file> ...来更新将被提交的内容)
#(使用git checkout - < file> ...放弃工作目录中的更改)

#modified:include / linux / netfilter / xt_connmark.h
#modified:include / linux / netfilter / xt_dscp.h
#modified:include / linux / netfilter / xt_mark.h
#modified:include / linux / netfilter / xt_rateest.h
#modified:include / linux / netfilter / xt_tcpmss.h
#modified:include / linux / netfilter_ipv4 / ipt_ecn.h
#modified:include / linux / netfilter_ipv4 / ipt_ttl.h
#修改:include / linux / netfilter_ipv6 / ip6t_hl.h
#修改:net / ipv4 / netfilter / ipt_ecn.c
#修改:net / netfilter / xt_dscp.c
#修改:net / netfilter / xt_hl.c
#modified:net / netfilter / xt_rateest .c
#modified:net / netfilter / xt_tcpmss.c

#未记录文件:
#(使用git add< file> ... )

#samples / hidraw /
没有更改添加到提交中(使用git add和/或git commit -a)
code>

这些变化从何而来,我想知道。
现在是最糟糕的部分。让我们看看如果我试图摆脱这些文件并再次检出它们会发生什么。

  axel @ macbook〜/ Depots / linux $ rm -Rf include net 
axel @ macbook〜/ Depots / linux $ git checkout - 。
axel @ macbook〜/ Depot / linux $ git status
#在分支主机上
#没有为commit提交更改:
#(使用git add< file> .. 。以更新将提交的内容)
#(使用git checkout - < file> ...放弃工作目录中的更改)

#modified:include / linux / netfilter / xt_CONNMARK.h
#modified:include / linux / netfilter / xt_DSCP.h
#modified:include / linux / netfilter / xt_MARK.h
#modified:include / linux / netfilter / xt_RATEEST.h
#modified:include / linux / netfilter / xt_TCPMSS.h
#modified:include / linux / netfilter_ipv4 / ipt_ECN.h
#modified:include / linux / netfilter_ipv4 / ipt_TTL.h
#modified:include / linux / netfilter_ipv6 / ip6t_HL.h
#modified:net / ipv4 / netfilter / ipt_ECN.c
#modified:net / netfilter / xt_DSCP.c
#modified:net / netfilter / xt_HL.c
#modified:net / netfilter / xt_RATEEST.c
#modified:net / netfilter / xt_TCPMSS.c

#未跟踪f iles:
#(使用git add< file> ...来包含将要提交的内容)

#samples / hidraw /
没有更改添加到提交(使用git add和/或git commit -a)


git checkout 操作似乎产生具有神秘变化的文件。
我试图进一步调查, 我想我已经消除了这些更改可能是由结束问题引起的可能性 。在$ $ b

  diff --git a中查看 git diff  /include/linux/netfilter/xt_CONNMARK.hb/include/linux/netfilter/xt_CONNMARK.h 
index 2f2e48e..efc17a8 100644
--- a / include / linux / netfilter / xt_CONNMARK.h
+++ b / include / linux / netfilter / xt_CONNMARK.h
@@ -1,6 +1,31 @@
- #ifndef _XT_CONNMARK_H_target
- #define _XT_CONNMARK_H_target
+#ifndef _XT_CONNMARK_H
+ #define _XT_CONNMARK_H

- #include< linux / netfilter / xt_connmark.h>
+#include< linux / types.h>

- #endif / * _ XT_CONNMARK_H_target * /
+ / * Copyright(C)2002,2004 MARA Systems AB< http://www.marasystems.com>
+ * Henrik Nordstrom< hno@marasystems.com>
+ *
+ *此程序是免费软件;您可以根据自由软件基金会出版的GNU通用公共许可证条款重新发布和/或修改
+ * it;版本2的许可证,或
+ *(可选)任何更新的版本。
+ * /

如果我明白这个权利,就会显示无法做出的变更通过改变一些行结尾,对吧?
我做的最后一件事是:试图找出更改的原创者,但显然这并不奏效。请参阅以下 git blame 输出。

  axel @ macbook〜/ Depots / linux $ git blame include / linux / netfilter / xt_CONNMARK.h 
00000000(还没有提交2011-10-25 20:00:56 +0200 1)#ifndef _XT_CONNMARK_H
00000000(尚未提交2011 -10-25 20:00:56 +0200 2)#define _XT_CONNMARK_H
2e4e6a17(Harald Welte 2006-01-12 13:30:04 -0800 3)
00000000(尚未兑现2011-10 -25 20:00:56 +0200 4)#include< linux / types.h>
0dc8c760(Jan Engelhardt 2008-01-14 23:38:34 -0800 5)
00000000(还没有承诺2011-10-25 20:00:56 +0200 6)/ * Copyright(C )2002,2004 MARA Systems AB< http://www.marasystems.com>
00000000(尚未提交2011-10-25 20:00:56 +0200 7)*作者:Henrik Nordstrom< hno@marasystems.com>
00000000(尚未提交2011-10-25 20:00:56 +0200 8)*
00000000(尚未提交2011-10-25 20:00:56 +0200 9)*此程序是免费软件;您可以重新发布它和/或修改
00000000(尚未提交2011-10-25 20:00:56 +0200 10)*它在GNU通用公共许可证条款下发布,由
发布00000000 (未承诺2011-10-25 20:00:56 +0200 11)*自由软件基金会;许可证的版本2或
00000000(尚未提交2011-10-25 20:00:56 +0200 12)*(可选)任何更新的版本。
00000000(尚未兑现2011-10-25 20:00:56 +0200 13)* /



问题



我错过了什么?我何时可能出错,以及如何解决这个问题?
感谢您的提示和评论!

解决方案

Linux源代码树的文件名仅在不同情况下有所不同, 有趣的在系统上遇到不区分大小写的文件系统。



您需要区分大小写的文件系统才能使用Linux源代码。

.h 是Git仓库中的两个不同文件,但是如果您的文件系统不区分大小写,那么您的结帐中一次只能存在一个。)


I am seeing a behaviour in Git which seems very mysterious to me. I keep a clone of the Linux repository from Github to play with Git locally. To be clear, I don't do much in this repository : I fetch changes, update master, checkout a specific version, and sometimes I try out a Git GUI to see what the visualization looks like on a big project. TLDR version: I never did any changes to the files in it.

Strange behaviour

Earlier today, I checked-out master and pulled changes from Github. Everything seemed to go fine. But I suspect it actually didn't. This is what git status looks like now.

axel@macbook ~/Depots/linux $ 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:   include/linux/netfilter/xt_connmark.h
#   modified:   include/linux/netfilter/xt_dscp.h
#   modified:   include/linux/netfilter/xt_mark.h
#   modified:   include/linux/netfilter/xt_rateest.h
#   modified:   include/linux/netfilter/xt_tcpmss.h
#   modified:   include/linux/netfilter_ipv4/ipt_ecn.h
#   modified:   include/linux/netfilter_ipv4/ipt_ttl.h
#   modified:   include/linux/netfilter_ipv6/ip6t_hl.h
#   modified:   net/ipv4/netfilter/ipt_ecn.c
#   modified:   net/netfilter/xt_dscp.c
#   modified:   net/netfilter/xt_hl.c
#   modified:   net/netfilter/xt_rateest.c
#   modified:   net/netfilter/xt_tcpmss.c
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   samples/hidraw/
no changes added to commit (use "git add" and/or "git commit -a")

Where do these changes come from, I wonder. Now comes the worst part. Let us see what happens if I try to get rid of those files and check them out again.

axel@macbook ~/Depots/linux $ rm -Rf include net
axel@macbook ~/Depots/linux $ git checkout -- .
axel@macbook ~/Depots/linux $ 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:   include/linux/netfilter/xt_CONNMARK.h
#   modified:   include/linux/netfilter/xt_DSCP.h
#   modified:   include/linux/netfilter/xt_MARK.h
#   modified:   include/linux/netfilter/xt_RATEEST.h
#   modified:   include/linux/netfilter/xt_TCPMSS.h
#   modified:   include/linux/netfilter_ipv4/ipt_ECN.h
#   modified:   include/linux/netfilter_ipv4/ipt_TTL.h
#   modified:   include/linux/netfilter_ipv6/ip6t_HL.h
#   modified:   net/ipv4/netfilter/ipt_ECN.c
#   modified:   net/netfilter/xt_DSCP.c
#   modified:   net/netfilter/xt_HL.c
#   modified:   net/netfilter/xt_RATEEST.c
#   modified:   net/netfilter/xt_TCPMSS.c
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   samples/hidraw/
no changes added to commit (use "git add" and/or "git commit -a")

Well, same thing. The git checkout operation seems to produce files with mysterious changes. I tried to investigate further, and I think I eliminated the possibility that these changes were caused by line-ending issues. See the beginning of a git diff below

diff --git a/include/linux/netfilter/xt_CONNMARK.h b/include/linux/netfilter/xt_CONNMARK.h
index 2f2e48e..efc17a8 100644
--- a/include/linux/netfilter/xt_CONNMARK.h
+++ b/include/linux/netfilter/xt_CONNMARK.h
@@ -1,6 +1,31 @@
-#ifndef _XT_CONNMARK_H_target
-#define _XT_CONNMARK_H_target
+#ifndef _XT_CONNMARK_H
+#define _XT_CONNMARK_H

-#include <linux/netfilter/xt_connmark.h>
+#include <linux/types.h>

-#endif /*_XT_CONNMARK_H_target*/
+/* Copyright (C) 2002,2004 MARA Systems AB <http://www.marasystems.com>
+ * by Henrik Nordstrom <hno@marasystems.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */

If I understand this right, this shows changes that cannot have been made by just changing some line endings, right? Last thing I did was: try to find out the originator of the changes, but obviously that did not work. See the following git blame output.

axel@macbook ~/Depots/linux $ git blame include/linux/netfilter/xt_CONNMARK.h
00000000 (Not Committed Yet 2011-10-25 20:00:56 +0200  1) #ifndef _XT_CONNMARK_H
00000000 (Not Committed Yet 2011-10-25 20:00:56 +0200  2) #define _XT_CONNMARK_H
2e4e6a17 (Harald Welte      2006-01-12 13:30:04 -0800  3) 
00000000 (Not Committed Yet 2011-10-25 20:00:56 +0200  4) #include <linux/types.h>
0dc8c760 (Jan Engelhardt    2008-01-14 23:38:34 -0800  5) 
00000000 (Not Committed Yet 2011-10-25 20:00:56 +0200  6) /* Copyright (C) 2002,2004 MARA Systems AB <http://www.marasystems.com>
00000000 (Not Committed Yet 2011-10-25 20:00:56 +0200  7)  * by Henrik Nordstrom <hno@marasystems.com>
00000000 (Not Committed Yet 2011-10-25 20:00:56 +0200  8)  *
00000000 (Not Committed Yet 2011-10-25 20:00:56 +0200  9)  * This program is free software; you can redistribute it and/or modify
00000000 (Not Committed Yet 2011-10-25 20:00:56 +0200 10)  * it under the terms of the GNU General Public License as published by
00000000 (Not Committed Yet 2011-10-25 20:00:56 +0200 11)  * the Free Software Foundation; either version 2 of the License, or
00000000 (Not Committed Yet 2011-10-25 20:00:56 +0200 12)  * (at your option) any later version.
00000000 (Not Committed Yet 2011-10-25 20:00:56 +0200 13)  */

Questions

What am I missing? When could I have gone wrong, and how to fix this? Thanks for your tips and remarks!

解决方案

The Linux source tree has filenames which differ in case only, which causes interesting failures on systems with case-insensitive filesystems.

You need a case-sensitive filesystem in order to work with the Linux source.

(include/linux/netfilter/xt_connmark.h and include/linux/netfilter/xt_CONNMARK.h are two different files in the Git repository, but only one can exist in your checkout at a time if your filesystem is case-insensitive.)

这篇关于奇怪的Git行为:神秘的变化无法撤消的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆