Я вижу поведение в Git, которое мне кажется очень загадочным.Я храню клон репозитория Linux из Github , чтобы играть с Git локально.Чтобы быть ясным, я мало что делаю в этом хранилище: я получаю изменения, обновляю master
, извлекаю конкретную версию, а иногда я пробую 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) */
Вопросы
Чего мне не хватает?Когда я мог ошибиться и как это исправить?Спасибо за ваши советы и замечания!