git分支切换时的时间戳问题
1、为什么git仓库没有保留文件修改时的时间戳?
摘自:https://git.wiki.kernel.org/index.php/Git_FAQ#Why_isn.27t_Git_preserving_modification_time_on_files.3F
Why isn't Git preserving modification time on files?
Modification time on files is a feature that affects build tools.
Most build tools compare the timestamp of the source(s) with the timestamp of the derived file(s).
If the source is newer, then a rebuild takes place, otherwise nothing happens. This speeds up the build process a lot.
Now consider what would happen if you check out another branch, and modification times were preserved. We assume you already have a fully-built project.
If a source file on that other branch has a timestamp that is older than that of the corresponding derived file, the derived file will not be built even if it is different, because the build system only compares modification times.
At best, you'll get some kind of weird secondary error; but most likely everything will look fine at first, but you will not get the same result as you would have with a clean build. That situation is unhealthy since you really do not know what code you are executing and the source of the problem is hard to find.
You will end up always having to make a clean build when switching branches to make sure you are using the correct source.
(Git bisect is another Git procedure that checks out old and new revisions where you need a reliable rebuild.)
Git sets the current time as the timestamp on every file it modifies, but only those. The other files are left untouched, which means build tools will be able to depend on modification time and rebuild properly. If build rules change, that can cause a failure anyway, but that is a far less common problem than accidentally not rebuilding.
2、为什么git仓库仅仅保留change commit 的修改时间戳信息,而没有保留文件的时间戳信息?
摘自:https://stackoverflow.com/questions/2179722/checking-out-old-file-with-original-create-modified-timestamps
I believe that the only timestamps recorded in the Git database are the author and commit timestamps. I don't see an option for Git to modify the file's timestamp to match the most recent commit, and it makes sense that this wouldn't be the default behavior (because if it were, Makefiles wouldn't work correctly).
You could write a script to set the modification date of your files to the the time of the most recent commit. It might look something like this:
IFS="
"
for FILE in $(git ls-files)
do
TIME=$(git log --pretty=format:%cd -n --date=iso -- "$FILE")
TIME=$(date -j -f '%Y-%m-%d %H:%M:%S %z' "$TIME" +%Y%m%d%H%M.%S)
touch -m -t "$TIME" "$FILE"
done
git分支切换时的时间戳问题的更多相关文章
- 进行分支切换时,出现error的修复方法
进行分支切换时,出现如此错误,导致无法正常切换:error: The following untracked working tree files would be overwritten by ch ...
- git 分支合并时如何忽略某个文件
[转]git 分支合并时如何忽略某个文件 - 神奇的旋风 - 博客园 https://www.cnblogs.com/xuan52rock/p/13268872.html Git - git-merg ...
- git分支切换的一些问题
关于git切换分支后该分支的修改会在另一个分支里面一起修改的问题 修改分支后导致稳定版的主分支里面的文件连带修改. 原因:切换分支前原分支没有提交,导致新建的文件或者文件夹,没有纳入版本管理,所以会被 ...
- git分支间切换注意点和bug分支的处理
目录 备注: 知识点 记一次分支合并问题状况 从分支点开始,不同分支修改工作区的内容(不添加到暂存区和提交),切换分支,工作区的内容是一样的. 必须在提交或者暂存当前暂存区的状态后,再切换或合并分支 ...
- Git~分支真的很轻
轻,让人觉得很爽 所有源代码管理工具都有管理分支的功能,git当然也不例外,而且git的分支是非常轻的,不像tfs,svn那样,复制一大堆代码,git只记录变化的内容,有本地分支与远程分支之分,原则上 ...
- idea中使用git进行clone、分支切换、pull、push等
转:https://blog.csdn.net/xiaobai__lee/article/details/81081128 https://blog.csdn.net/geng31/article/d ...
- 【IntelliJ IDEA】在idea上操作 git分支合并【如何将远程swagger分支 合并到 远程 master分支上】【如何切换 本地分支】
============================================ 明确一点: 如果项目交给git管理了[如何将项目交给git管理:https://www.cnblogs.com ...
- Git分支,合并,切换分支的使用
1.创建合并分支 在我们每次的提交,Git都把它们串成一条时间线,这条时间线就是一个分支.截止到目前,只有一条时间线,在Git里,这个分支叫主分支,即master分支.HEAD指针严格来说不是指向提交 ...
- 版本控制git之二 分支 切换分支 创建分支 合并 删除
版本控制git之二 分支 有人把 Git 的分支模型称为它的`‘必杀技特性’',也正因为这一特性,使得 Git 从众多版本控制系统中脱颖而出. 为何 Git 的分支模型如此出众呢? Git 处 ...
随机推荐
- 通过GCEASY 和 jfr 发现运行时问题
进入 /dev/shm 目录 ,gc-xxx-xx 的gc 文件 ,上次 gceasy 进行分析 另外 ,通过打开 飞行记录器 , 打开jmc 通过jmx 端口连接上去 ,并启用飞行记录器 ...
- SQL Server - 使用 Merge 语句实现表数据之间的对比同步
表数据之间的同步有很多种实现方式,比如删除然后重新 INSERT,或者写一些其它的分支条件判断再加以 INSERT 或者 UPDATE 等.包括在 SSIS Package 中也可以通过 Lookup ...
- windows环境安装zabbix客户端
安装windows版zabbix客户端 一.下载客户端 在数据盘新建一个zabbix_agent目录 浏览器打开 https://www.zabbix.com/download_agents 选择”z ...
- git库初次下载
1.右键Git Batch Here==>输入 git config --list 确认2.再次输入ssh-keygen -t rsa -C “修改后的邮箱” 3.回车多次 找到 生成序列目录 ...
- jmeter 在linux服务器的安装和运行;
linux环境下使用jmeter进行压力测试 标签(空格分隔): linux环境,jmeter linux环境下使用就meter进行压力测试: linux环境部署: 在Linux服务器先安装jdk: ...
- js 创建对象的几种方法
1. 使用object创建 var person = new Object(); person.name = "Tom"; person.age = "29"; ...
- Structured streaming
Structured streaming是spark 2.0以后新增的用于实时处理的技术.与spark streaming不同的是,Structured streaming打开了数据源到数据落地之间的 ...
- MySQL 按指定字段自定义列表排序
问题描述 大家都知道, mysql 中按某字段升序排列的 SQL 为 (以 id 为例, 下同): SELECT * FROM `MyTable` WHERE `id` IN (1, 7, 3, 5) ...
- 无法加载DLL"***.dll":找不到指定的模块
加载dll的路径不对. 绝对路径不合适,可以换成相对路径. 比如: 把dll放入bin目录下的debug或者release下,然后就可以直接“test.dll”了.不用加路径了. 注意:路径必须与发布 ...
- oracle 中更新update不成功的原因
oracle 中执行insert into 与delete 都正常,但是执行update 却没有反应. 原因: 是因为记录锁.这种只有update无法执行其他语句可以执行的其实是因为记录锁导致的,在o ...