gpt4 book ai didi

linux - Git : mysterious changes cannot be undone 的奇怪行为

转载 作者:IT王子 更新时间:2023-10-29 00:20:24 26 4
gpt4 key购买 nike

我在 Git 中看到一个对我来说似乎非常神秘的行为。我保留了来自 Github 的 Linux 存储库的克隆。在本地玩 Git。明确地说,我在这个存储库中没有做太多事情:我获取更改、更新 master、 checkout 特定版本,有时我尝试使用 Git GUI 来查看可视化在大项目。TLDR 版本:我从未对其中的文件进行任何更改

奇怪的行为

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

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")

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

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")

嗯,同样的事情。git checkout 操作似乎产生了具有神秘变化的文件。我尝试进一步调查,我认为我排除了这些更改是由行结束问题引起的可能性。请参阅下面的 git diff 的开头

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.
+ */

如果我没理解错的话,这表明不能仅通过更改一些行结尾来进行更改,对吗?我做的最后一件事是:尝试找出更改的发起者,但显然那没有用。请参阅以下 git blame 输出。

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) */

问题

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

最佳答案

Linux 源代码树的文件名仅大小写不同,这会在不区分大小写的文件系统上导致有趣失败。

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

(include/linux/netfilter/xt_connmark.hinclude/linux/netfilter/xt_CONNMARK.h在Git仓库中是两个不同的文件,但是只有一个可以如果您的文件系统不区分大小写,则一次存在于您的 checkout 中。)

关于linux - Git : mysterious changes cannot be undone 的奇怪行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7893827/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com