Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux Git的奇怪行为:神秘的变化无法撤销_Linux_Macos_Git_Git Checkout - Fatal编程技术网

Linux Git的奇怪行为:神秘的变化无法撤销

Linux Git的奇怪行为:神秘的变化无法撤销,linux,macos,git,git-checkout,Linux,Macos,Git,Git Checkout,我在Git中看到了一种行为,这对我来说非常神秘。 我从中保留了一个Linux存储库的克隆,以便在本地使用Git。明确地说,我在这个存储库中没有做太多工作:我获取更改、更新master、签出特定的版本,有时我还尝试使用Git GUI来查看大型项目上的可视化效果。 TLDR版本:我从未对其中的文件做过任何更改 奇怪的行为 今天早些时候,我签出了master,并从Github中提取了更改。一切似乎都很顺利。但我怀疑事实并非如此。这就是现在git状态的样子 axel@macbook ~/Depots/l

我在Git中看到了一种行为,这对我来说非常神秘。 我从中保留了一个Linux存储库的克隆,以便在本地使用Git。明确地说,我在这个存储库中没有做太多工作:我获取更改、更新
master
、签出特定的版本,有时我还尝试使用Git GUI来查看大型项目上的可视化效果。 TLDR版本:我从未对其中的文件做过任何更改

奇怪的行为 今天早些时候,我签出了
master
,并从Github中提取了更改。一切似乎都很顺利。但我怀疑事实并非如此。这就是现在git状态的样子

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")
如果我理解正确的话,这表明仅仅改变一些行尾是不可能的,对吗? 我所做的最后一件事是:试图找出变更的发起人,但显然这不起作用。请参见下面的
git-dull
输出

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)  */
axel@macbook~/Depots/linux$git include/linux/netfilter/xt\u CONNMARK.h
00000000(尚未承诺)2011-10-25 20:00:56+02001
00000000(尚未提交2011-10-25 20:00:56+02002)定义
2e4e6a17(哈拉尔德世界报2006-01-1213:30:04-0800 3)
00000000(尚未承诺2011-10-25 20:00:56+02004)#包括
0dc8c760(Jan Engelhardt 2008-01-14 23:38:34-0800 5)
00000000(尚未承诺2011-10-25 20:00:56+02006)/*版权所有(C)20022004 MARA Systems AB
00000000(尚未承诺2011-10-25 20:00:56+02007)*由Henrik Nordstrom提供
00000000(尚未承诺2011-10-25 20:00:56+02008)*
00000000(尚未承诺2011-10-25 20:00:56+02009)*此程序为自由软件;您可以重新分发和/或修改它
00000000(尚未承诺2011-10-25 20:00:56+020010)*根据发布的GNU通用公共许可证条款
00000000(尚未提交2011-10-25 20:00:56+ 0200 11)*自由软件基金会;许可证的第2版,或
00000000(尚未提交2011-10-25 20:00:56+020012)*(由您选择)任何更高版本。
00000000(尚未承诺2011-10-25 20:00:56+020013)*/
问题 我错过了什么?我什么时候会出错,如何解决?
谢谢你的提示和评论

尝试更新子模块。当存储库中包含的子模块被更新时,我遇到了一些奇怪的、有点类似的问题。执行git子模块更新可以做到这一点。

Linux源代码树中的文件名仅在大小写上有所不同,这会在具有不区分大小写的文件系统的系统上导致有趣的故障

为了使用Linux源代码,您需要一个区分大小写的文件系统


include/linux/netfilter/xt_connmark.h
include/linux/netfilter/xt_connmark.h
是Git存储库中的两个不同文件,但如果文件系统不区分大小写,则一次只能在签出中存在一个文件。)

正如@ephemient所说的,这是因为文件系统不区分大小写。我猜你在用Mac的HFS

对于Mac上的简单解决方案,您可以创建磁盘映像,使用“区分大小写的日志HFS+”格式化磁盘映像:

hdiutil create-type SPARSE-fs'区分大小写的日志HFS+'-size 40g~/git.dmg

然后通过
open~/git.dmg
装载磁盘映像

然后在可装载卷中执行所有
git clone
git checkout
操作



或者您需要一些第三方工具将HFS+从不区分大小写转换为区分大小写。据我所知,一些Mac应用程序是在不区分大小写的文件系统上制作的,因此如果您进行此转换,其中一些应用程序可能无法工作。

您是否尝试过
git reset--hard
?它应该将分支重置为上次提交时的状态。也就是说,我不知道为什么git checkout不起作用……是的,我知道。如果您愿意,我可以发布输出,但基本上它只会提醒我
HEAD
在哪里。它返回0。尽管如此,在这之后,
git状态
仍保持不变。重复使用git 2.20(2018年第4季度),您将在git克隆过程中收到警告,包括任何区分大小写的阴影:请参见“”。谢谢,这就是我一直在寻找的答案!可惜的是,周围没有不引人注目的工作-(同样的事情也发生在我身上,虽然我在linux中,但我使用的存储库中有一个符号链接,git Dull并没有完全识别这个符号链接,所以每一行都显示为未提交。
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.
+ */
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)  */