合并时忽略某些xml行 [英] Ignoring certain xml lines when merging

查看:91
本文介绍了合并时忽略某些xml行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的对象库文件中有一个日期行,它不会自动处理git,所以每当两个版本库合并时,我们基本上需要选择我们想保留的日期。日期本身从不使用,也不需要,并且存储库中的每个对象都有一个日期(每个xml约为50),所以这是一个令人讨厌的任务。



<有没有办法让git忽略日期行?日期是否保持原来的状态并不重要,这并不重要。或者让git总是用新的日期覆盖旧的日期。它看起来像这样(挪威的日期):

 < qtpRep:LastUpdateTime> 6。 mai 2014 12:03:22< / qtpRep:LastUpdateTime> 

对象库文件是通过UFT创建/更新的xml文件,这意味着代码是自动生成的,因此在这些文件中持续更新日期。 /git-scm.com/docs/gitattributesrel =nofollow noreferrer> a .gitattributes 文件以便

$ b

(From Pro Git Book

这将允许自动 git add < qtpRep:LastUpdateTime> 内容设置为固定值,而不是自动生成的值。

  *。xml filter = fixedDate 

git config --global filter.fixedDate.clean cleanDate

在clean fixedDate 过滤器,这里 cleanDate ,可以解析被添加的文件的内容,并用固定的日期替换日期。



该脚本和 .gitattributes 可以存储和分发到同一个git仓库中,但筛选器需要被所有用户激活才能在所有用户中一致使用克隆回购。


We are using git through sourcetree for a project involving HP UFT object repositories.

In our object repository files there is a date line, which is not automatically handled by git, so every time two repositories are merged we basically need to pick which date we want to keep. The date itself is never used and is not needed, and there is a date for every single object in the repository(~50 for each xml) so this is an annoying task.

Is there a way to make git ignore the date line? It doesn't matter if the date stays the way it was instead of being updated. Alternatively have git always overwrite the old date with the new date. It looks like this (norwegian date):

<qtpRep:LastUpdateTime>6. mai 2014 12:03:22</qtpRep:LastUpdateTime>

The object repository files are xml files created/updated through UFT which means that the code is autogenerated, hence the continous update of dates within these files.

解决方案

You could use a clear content filer in a .gitattributes file in order to

(From Pro Git Book)

That would allow, automatically on git add, to set the element <qtpRep:LastUpdateTime> content to a fixed value instead of the auto-generated one.

*.xml     filter=fixedDate

git config --global filter.fixedDate.clean cleanDate

The script declared in the "clean" fixedDate filter, here cleanDate, can parse the content of the file being added, and replace the date by a fixed one.

That script and the .gitattributes can be stored and distributed in the same git repo, but the filter needs to be activated by all users in order to be used consistently across all cloned repos.

这篇关于合并时忽略某些xml行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆