Ignoring certain xml lines when merging

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.

  • Storyboard Deleted by Git and “You need to resolve your current index first” error with Xcode
  • Pull Master from featured branch
  • How to tag an older commit in Git?
  • Managing two ssh keys
  • Git is showing files as changed, even though files are byte-for-byte identical
  • `git checkout source_branch <paths>` and specify the file on the current branch?
  • 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.

  • How to create git branch from current files without changing master?
  • how to remove changes since last git commit
  • git-svn folder from existing custom SVN
  • Why is there a `remotes/origin/HEAD -> origin/master` entry in my `git branch -l -a` output?
  • Git bundle adding remote
  • ls output colors for specific files?
  • 2 Solutions collect form web for “Ignoring certain xml lines when merging”

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

    http://git-scm.com/figures/18333fig0703-tn.png

    (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.

    (How do I write complete comments? All I managed to do with comments on stackoverflow was to write a single continous line of text.)

    I created a repository and added a file called .gitattributes with a single line:

    *.xml filter=fixedDate
    

    Then I ran the following in windows cmd:

    git config --global filter.fixedDate.clean 'perl -pe "s/\\\$Date[^\\\$]*\\\$/\\\$Date\\\$/"'
    

    This only returned the git config options. So I assume it ran correctly? Or does git return the options instead of an error message?

    I then pushed an .xml file with the following content:

    $Date: 123$
    

    The file was pushed normally with no changes to the contents.

    The explanation on http://git-scm.com/docs/gitattributes didn’t really help much.

    Git Baby is a git and github fan, let's start git clone.