Как я могу удалить измененные файлы? - PullRequest
28 голосов
/ 26 ноября 2011

Это репозиторий ядра Linux 2.6.Я клонирую его на свой локальный хост.

После этого.Я не сделал никаких изменений.Но когда я "git status".Я нашел 13 измененных файлов.Я хочу отказаться от них, но не могу.

> luke@Macbook-Pro~/Documents/workspace/linuxkernel/linux-2.6$ 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")
> luke@Macbook-Pro~/Documents/workspace/linuxkernel/linux-2.6$ git
> checkout -- include/linux/netfilter/xt_connmark. h
> luke@Macbook-Pro~/Documents/workspace/linuxkernel/linux-2.6$ 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")
> luke@Macbook-Pro~/Documents/workspace/linuxkernel/linux-2.6$ git
> checkout -- include/linux/netfilter/xt_dscp.h
> luke@Macbook-Pro~/Documents/workspace/linuxkernel/linux-2.6$ 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")
> luke@Macbook-Pro~/Documents/workspace/linuxkernel/linux-2.6$ 
> 

отредактировано:

luke@Macbook-Pro~/Documents/workspace/linuxkernel/linux-2.6$ git config -l
user.name=99999
user.email=99999
alias.co=checkout
core.editor=mate -w
core.edit=mate -w
core.excludesfile=/Users/luke/.gitignore_global
difftool.sourcetree.cmd=opendiff "$LOCAL" "$REMOTE"
difftool.sourcetree.path=
mergetool.sourcetree.cmd=/Applications/SourceTree.app/Contents/Resources/opendiff-w.sh "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED"
mergetool.sourcetree.trustexitcode=true
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true

отредактировано: это мой файл различий:

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.
+ */
+
+enum {
+   XT_CONNMARK_SET = 0,
+   XT_CONNMARK_SAVE,
+   XT_CONNMARK_RESTORE
+};
+
+struct xt_connmark_tginfo1 {
+   __u32 ctmark, ctmask, nfmask;
+   __u8 mode;
+};
+
+struct xt_connmark_mtinfo1 {
+   __u32 mark, mask;
+   __u8 invert;
+};
+
+#endif /*_XT_CONNMARK_H*/
diff --git a/include/linux/netfilter/xt_DSCP.h b/include/linux/netfilter/xt_DSCP.h
index 648e0b3..15f8932 100644
--- a/include/linux/netfilter/xt_DSCP.h
+++ b/include/linux/netfilter/xt_DSCP.h
@@ -1,26 +1,31 @@
-/* x_tables module for setting the IPv4/IPv6 DSCP field
+/* x_tables module for matching the IPv4/IPv6 DSCP field
  *
  * (C) 2002 Harald Welte <laforge@gnumonks.org>
- * based on ipt_FTOS.c (C) 2000 by Matthew G. Marsh <mgm@paktronix.com>
  * This software is distributed under GNU GPL v2, 1991
  *
  * See RFC2474 for a description of the DSCP field within the IP Header.
  *
- * xt_DSCP.h,v 1.7 2002/03/14 12:03:13 laforge Exp
+ * xt_dscp.h,v 1.3 2002/08/05 19:00:21 laforge Exp
 */
-#ifndef _XT_DSCP_TARGET_H
-#define _XT_DSCP_TARGET_H
-#include <linux/netfilter/xt_dscp.h>
+#ifndef _XT_DSCP_H
+#define _XT_DSCP_H
+
 #include <linux/types.h>

-/* target info */
-struct xt_DSCP_info {
+#define XT_DSCP_MASK   0xfc    /* 11111100 */
+#define XT_DSCP_SHIFT  2
+#define XT_DSCP_MAX    0x3f    /* 00111111 */
+
+/* match info */
+struct xt_dscp_info {
    __u8 dscp;
+   __u8 invert;
 };

-struct xt_tos_target_info {
-   __u8 tos_value;
+struct xt_tos_match_info {
    __u8 tos_mask;
+   __u8 tos_value;
+   __u8 invert;
 };

-#endif /* _XT_DSCP_TARGET_H */
+#endif /* _XT_DSCP_H */
diff --git a/include/linux/netfilter/xt_mark.h b/include/linux/netfilter/xt_mark.h
index ecadc40..41c456d 100644
--- a/include/linux/netfilter/xt_mark.h
+++ b/include/linux/netfilter/xt_mark.h
@@ -1,15 +1,6 @@
-#ifndef _XT_MARK_H
-#define _XT_MARK_H
+#ifndef _XT_MARK_H_target
+#define _XT_MARK_H_target

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

-struct xt_mark_tginfo2 {
-   __u32 mark, mask;
-};
-
-struct xt_mark_mtinfo1 {
-   __u32 mark, mask;
-   __u8 invert;
-};
-
-#endif /*_XT_MARK_H*/
+#endif /*_XT_MARK_H_target */
diff --git a/include/linux/netfilter/xt_rateest.h b/include/linux/netfilter/xt_rateest.h
index d40a619..6605e20 100644
--- a/include/linux/netfilter/xt_rateest.h
+++ b/include/linux/netfilter/xt_rateest.h
@@ -1,37 +1,15 @@
-#ifndef _XT_RATEEST_MATCH_H
-#define _XT_RATEEST_MATCH_H
+#ifndef _XT_RATEEST_TARGET_H
+#define _XT_RATEEST_TARGET_H

Из-заукладывать ограничение длины переполнения.Здесь можно скопировать только часть файла diff.

все еще нужна помощь

Ответы [ 10 ]

48 голосов
/ 26 ноября 2011

A git reset --hard HEAD должен решить проблему.

13 голосов
/ 06 марта 2013

Это происходит потому, что ядро ​​Linux включает файлы с одинаковыми именами (но в разных случаях):

include/linux/netfilter/xt_connmark.h 
include/linux/netfilter/xt_CONNMARK.h
12 голосов
/ 27 июня 2015

Вы можете использовать:

git checkout .

Чтобы понять разницу между git checkout и git reset, обратитесь к следующему вопросу:

В чем разница между «git reset»"и" git checkout "?

7 голосов
/ 21 апреля 2018

Путем последовательного ввода этих команд.

git stash
git stash drop

git stash сохраняет измененные файлы в стеке для последующего извлечения.

git stash drop отбрасывает их.

6 голосов
/ 01 июня 2012

эта проблема была вызвана для меня не чувствительной к регистру файловой системой (например, в Mac OS). Вы можете создать образ диска с учетом регистра, смонтировать его и выполнить там работу git, либо использовать другую ОС для разработки.

3 голосов
/ 26 ноября 2011

Есть еще одна возможность, когда проблема связана с файловым режимом.В этом случае вы можете попробовать git config core.filemode false

Дополнительная информация: Как заставить Git игнорировать изменения режима файла (chmod)?

Редактировать:

Другой возможностью могут быть окончания строк, попробуйте установить git config core.autocrlf true|false|input и посмотреть, будет ли это иметь значение.

Дополнительная информация: Почему я должен использовать core.autocrlf = true в Git?

3 голосов
/ 26 ноября 2011

Вы также можете удалить неотслеживаемые файлы с помощью чистой

git clean -f
2 голосов
/ 26 октября 2018

modified: specific_filename

git checkout specific_filename

Это безопаснее, чем удалить все сразу, используя git checkout .

2 голосов
/ 17 апреля 2016

Вопрос похож на Странное поведение Git: таинственные изменения не могут быть отменены

Вам нужна регистронезависимая файловая система. Если ваш компьютер Apple Mac, как и я, вы можете создать диск с учетом регистра.

hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 25g ~/android.dmg

hdiutil resize -size <new-size-you-want>g ~/android.dmg.sparseimage

# mount the android file image
function mountAndroid { hdiutil attach ~/android.dmg.sparseimage -mountpoint /Volumes/android; }

# unmount the android file image
function umountAndroid() { hdiutil detach /Volumes/android; }
0 голосов
/ 20 февраля 2019

использовать git reset HEAD <file>..., чтобы отключить

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...