I often switch back and forth between branches. I have a script which pushes the contents of the checkout to a ‘running’ environment where I can see the code run and test it (it’s a web app). This push script uses rsync at its heart and it uses timestamps to detect what files should really be transferred. Because ‘git-checkout’ seems to set the timestamps on the files to the current time, rsync reports all files are being pushed up, only because timestamps will be updated.
How can I have ‘git-checkout’ retain timestamps when switching between branches so that rsync will report only content changes?
I do not want to use rsync’s checksum argument as it is very slow.
The reason that
git checkoutupdates timestamps is that almost all build systems for source code depend on timestamps to determine if targets need to be rebuilt. Ifgit checkoutdid not update timestamps on files when they are updated, these build systems would not correctly do an incremental build. In fact,git checkoutshould only update timestamps on files that have changed.rsyncshould be efficient in updating time stamps, and not transfer any data if only metadata has changed. You can verify this with the "speedup". You can also ask recent versions ofrsyncto itemize changes with the-iflag. You can tellrsyncnot to use timestamps (and only use checksums) by leaving out-aor-t, but that’s not recommended by thersync(1)man page.