N
N
Nikolai Stupak2014-10-19 13:53:14
git
Nikolai Stupak, 2014-10-19 13:53:14

How to pull changes to a subdirectory of a git repository by applying the remote version of the files?

I have a project with the following structure:

project
     |----data
             |----1.xml
             |----2.xml
     |----subprojects
             |----subproject1
             |----subproject2

where subproject1 and subproject2 have the same structure as project.
All this is in the git repository. The data directory contains xml files, which are actually text files, but are treated as binary files. Those. I can’t merge them, but when updating, I just need to roll those versions that are in the remote repository.
Actually, this is the task: to pull out the changes in the data directory for any project (both root and child) so that the remote version is completely rolled?
So far, it has been possible to do it in the following way.
git rm -r ${projectDir}/data
git read-tree --prefix=${projectDir}/data/ -u origin/master:${projectDir}/data
git commit -m "Updated ${projectName}"

but it doesn't fit because the library I use to work with git doesn't support the read-tree command.
Yes, this method works, but it seems to me that there is a more civilized way to solve such a problem. For example, in the .gitattributes file, specify the merge strategy merge=ours for non-replaceable files, and recursive -Xtheirs for replacement files. merge=ours I can specify, but how do I specify options for the recursive strategy in .gitattributes?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question