git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: preserving mtime

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 16, 2007, 10:21 UTC
Message-ID
<7v1waqze1b.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<473D63F9.4010201@inrim.it>
Fabrizio Pollastri <f.pollastri@inrim.it> writes:
> is it possible to tell git to preserve the file modification time in a
> checked out copy? It is useful when managing web files, where mtime is
> tested by spiders for download decisions.

"git checkout branchA" after "git checkout branchB" would not touch "file" if "file" are identical between two branches, so the modification time is already preserved.

If the contents of "file" from the version you would want to check out is different from the version you previously checked out, and you still want to keep the old timestamp, then you are trying to do something that a normal SCM user would actively not want (e.g. doing so would screw up the build systems such as "make"). Such a specialized need usually is addressed by the build and install procedure of the application (in your case, a website management). Maybe your current build procedure may blindly copy when installing:

	install: web.html
        	$(install) web.html $(dest)/var/www/web.html

but you may want to ignore certain classes of changes and avoid re-installing to help crawlers. You would do:

	install = ./myinstall.sh
	install: web.html
        	$(install) web.html $(dest)/var/www/web.html
and then ./myinstall.sh might look like:
	#!/bin/sh
	test -f "$2" &&
        compare-ignoring-minor-changes "$1" "$2" && exit 0
	install "$1" "$2"
Previous: Jakub NarebskiNext: Erik Warendorph
Message 13 of 14 in “preserving mtime”
  1. Fabrizio PollastriNov 16, 2007
  2. Andreas EricssonNov 16, 2007
  3. Wayne DavisonNov 17, 2007
  4. Mike HommeyNov 18, 2007
  5. Martin LanghoffNov 18, 2007
  6. David BrownNov 18, 2007
  7. Martin LanghoffNov 18, 2007
  8. David BrownNov 18, 2007
  9. Jan HudecNov 18, 2007
  10. Robin RosenbergNov 18, 2007
  11. Johannes SchindelinNov 19, 2007
  12. Jakub NarebskiNov 16, 2007
  13. Junio C HamanoNov 16, 2007
  14. Erik WarendorphNov 16, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.