Pregunta

En el GitFaq puedo leer, que

  

Git ajusta la hora actual como la fecha y hora de cada archivo se modifica, pero sólo aquellos.

Sin embargo, he intentado esta secuencia de comandos ( EDIT: añade la secuencia de comandos completa)

$ 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

Ahora mi pregunta: ¿Por qué cambiar la fecha y hora de git fileb archivo? Yo esperaría que la marca de tiempo para estar sin cambios.

¿Son mis comandos que causan un problema?
Tal vez es posible hacer algo como un lugar git checkout . --modified?

Estoy utilizando git version 1.6.5.1.1367.gcd48 bajo mingw32 / Windows XP.

¿Fue útil?

Solución

Esto no se produce en un sistema de archivos de Linux. He probado el mismo escenario que describes y mis tiempos de modificación se conservan para los archivos que me quedan intactos:

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

Sospecho que esto es un error desconocido en la acumulación mingw32 de Git, es posible que desee informar a los desarrolladores: http://code.google.com/p/msysgit/issues/list

Sería interesante ver si se modifica el sello modificación BusTests.h cuando sólo pago y envío el archivo modificado:

git checkout -- tests/BusTests.c

Otros consejos

git ls-files -m | xargs git co --

ayuda a obtener sólo los archivos modificados. Pero todavía no puedo explicar, por qué git checkout causa los problemas.

Me he dado cuenta de un problema similar con git reset --hard partir de la versión 1.7.0.2 msysgit. Antes, sólo sería cambiar las marcas de tiempo de los archivos modificados. Ahora, cambia las marcas de tiempo de todos los archivos. Fui de nuevo a usar 1.6.5.1 por eso, porque no tiene este problema:)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top