4

私が読むことができるGitFaqでは、

Git は、変更するすべてのファイルのタイムスタンプとして現在の時刻を設定しますが、それらのみを設定します。

ただし、次のコマンド シーケンスを試しました。

$ git init test && cd test
Initialized empty Git repository in d:/test/.git/

$ touch filea fileb

$ git add .

$ git commit -m "first commit"
[master (root-commit) fcaf171] first commit
 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 filea
 create mode 100644 fileb

$ ls -l > filea

$ touch fileb -t 200912301000

$ ls -l
total 1
-rw-r--r--    1 exxxxxxx Administ      132 Feb 12 18:36 filea
-rw-r--r--    1 exxxxxxx Administ        0 Dec 30 10:00 fileb

$ git status -a
warning: LF will be replaced by CRLF in filea
# On branch master
warning: LF will be replaced by CRLF in filea
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#






#       modified:   filea
#

$ git checkout .

$ ls -l
total 0
-rw-r--r--    1 exxxxxxx Administ        0 Feb 12 18:36 filea
-rw-r--r--    1 exxxxxxx Administ        0 Feb 12 18:36 fileb

Git が file のタイムスタンプを変更したのはなぜfilebですか? タイムスタンプは変わらないと思います。

私のコマンドが問題を引き起こしていますか? git checkout . --modified代わりにaのようなことをすることは可能でしょうか?

git version 1.6.5.1.1367.gcd48MinGW と Windows XP で使用しています。

4

3 に答える 3

2

これは Linux ファイルシステムでは発生しません。あなたが説明した正確なシナリオをテストしましたが、変更時間はそのままにしておいたファイルに保存されています。

sean@SEAN-PC:~/Desktop/test$ ls -la tests/BusTests.*
-r--r--r-- 1 sean sean 8 2010-02-11 11:53 tests/BusTests.c
-r--r--r-- 1 sean sean 1 2010-02-11 11:51 tests/BusTests.h

sean@SEAN-PC:~/Desktop/test$ git status -a
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   tests/BusTests.c
#

sean@SEAN-PC:~/Desktop/test$ git checkout .

sean@SEAN-PC:~/Desktop/test$ ls -la tests/BusTests.*
-r--r--r-- 1 sean sean 1 2010-02-11 11:55 tests/BusTests.c
-r--r--r-- 1 sean sean 1 2010-02-11 11:51 tests/BusTests.h

これは、Git の MinGW ビルドの未知のバグであると思われます。開発者に報告することをお勧めします: http://code.google.com/p/msysgit/issues/list

変更されたファイルのみをチェックアウトしたときに、BusTests.h 変更スタンプが変更されているかどうかを確認すると興味深いでしょう。

git checkout -- tests/BusTests.c
于 2010-02-11T12:10:38.587 に答える
0
git ls-files -m | xargs git co --

変更されたファイルのみをチェックアウトするのに役立ちます。git checkoutしかし、なぜ問題が発生するのか、まだ説明できません。

于 2010-02-11T11:53:52.580 に答える
0

msysgit バージョン 1.7.0.2 の時点で、git reset --hard に関する同様の問題に気付きました。以前は、変更されたファイルのタイムスタンプのみが変更されました。これで、すべてのファイルのタイムスタンプが変更されます。この問題がないため、その理由で1.6.5.1の使用に戻りました:)

于 2010-05-12T15:09:02.003 に答える