git checkout - 如何在切换分支时维护时间戳? [英] git checkout - how can I maintain timestamps when switching branches?
问题描述
如何能在分支之间切换时,我有git-checkout保留时间戳,这样rsync只会报告内容更改?
我不想使用rsync的校验和参数,因为它非常慢。 git checkout
更新时间戳的原因是几乎所有的构建源代码系统依赖于时间戳来确定目标是否需要重新构建。如果 git checkout
在更新文件时未更新时间戳,则这些构建系统将无法正确执行增量构建。事实上, git checkout
应该只更新已更改文件的时间戳。
rsync
在更新时间戳时应该是有效的,并且如果只有元数据已更改,则不传输任何数据。你可以用加速来验证。您还可以请求 rsync
的最近版本使用 -i
标志逐项列出更改。您可以通过忽略 -a
或<$ c $来告诉 rsync
不使用时间戳(并且只使用校验和) c> -t 但这不是由 rsync(1)
手册页推荐的。
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 checkout
updates timestamps is that almost all build systems for source code depend on timestamps to determine if targets need to be re-built. If git checkout
did not update timestamps on files when they are updated, these build systems would not correctly do an incremental build. In fact, git checkout
should only update timestamps on files that have changed.
rsync
should 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 of rsync
to itemize changes with the -i
flag. You can tell rsync
not to use timestamps (and only use checksums) by leaving out -a
or -t
but that's not recommended by the rsync(1)
man page.
这篇关于git checkout - 如何在切换分支时维护时间戳?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!