git checkout - how can I maintain timestamps when switching branches?

前端 未结 3 1719
一个人的身影
一个人的身影 2021-01-02 03:21

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

3条回答
  •  一向
    一向 (楼主)
    2021-01-02 03:51

    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.

提交回复
热议问题