我正在寻找一个合适的解决方案来删除我的存储库历史记录中的唯一时间戳更改。
如果你想知道我在这里做什么:我正在尝试建立一个git存储库,它基于一个软件下载的每晚zip存档,每天所有文件都带有日期的时间戳...但实际上并没有改变。为了保持实际的变化,我想摆脱这些变化。
我已经使用filter-branch来删除子目录。有人知道如何实现这个目标吗?
我有一些额外的观点:
附加
问题1:我如何知道实际更改了哪些文件?
好的,我举两个例子。第一个实际上包含一个变化,第二个只包含冲压。
在我的示例中,时间戳总是在第5行。我的目标是删除 commit A 中更改的一行并消除 commit B 。
示例提交A(之前)
a file with a header
a file with a header
a file with a header
/*
Build date: 2013-24-05 11:01:01 (02129bb861061d1a052c592e2dc6b383)
*/
other stuff
other stuff
something before the change
other stuff
示例提交A(之后)
a file with a header
a file with a header
a file with a header
/*
Build date: 2013-25-05 11:01:01 (57cec4137b614c87cb4e24a3d003a3e0)
*/
other stuff
other stuff
something after the change
other stuff
示例提交B(之前)
a file with a header
a file with a header
a file with a header
/*
Build date: 2013-24-05 11:01:01 (02129bb861061d1a052c592e2dc6b383)
*/
other stuff
other stuff
something which is not altered
other stuff
示例提交B(之后)
a file with a header
a file with a header
a file with a header
/*
Build date: 2013-25-05 11:01:01 (57cec4137b614c87cb4e24a3d003a3e0)
*/
other stuff
other stuff
something which is not altered
other stuff
答案 0 :(得分:1)
简短版本:使用git filter-branch --tree-filter
和过滤器删除所有文件中的提交标记。类似的东西:
find . -name "*" -print | xargs sed -i 's/**commit-stamp-pattern**//g'
Git会处理剩下的事情。
以下是使用perl删除这些注释的方法:
find . -name "*" -print | xargs perl -i -pe 'undef $/; s!^/\*\nBuild date: \d{4}-.*\n\*/\n!!m'
(只有当你的文件名都没有空格时才会有效。)