0

I am working with git p4 rebase and git LFS. unfortunately after syncing the P4 contents to local git repo, it removes all the existing LFS tracked files from .gitattributes, and adds files to .gitattributes that were synced.

example:

Local and remote .gitattributes file before sync

    File 1 filter=lfs diff=lfs merge=lfs -text
    File 2 filter=lfs diff=lfs merge=lfs -text
    File 3 filter=lfs diff=lfs merge=lfs -text

local .gitattributes file after sync

    File 4 filter=lfs diff=lfs merge=lfs -text
    File 5 filter=lfs diff=lfs merge=lfs -text

Now, if I push to remote, I will lose tracking on 1,2,3. So before I push I need to merge the remote .gitattributes file with the local .gitattributes file to obtain

    File 1 filter=lfs diff=lfs merge=lfs -text
    File 2 filter=lfs diff=lfs merge=lfs -text
    File 3 filter=lfs diff=lfs merge=lfs -text
    File 4 filter=lfs diff=lfs merge=lfs -text
    File 5 filter=lfs diff=lfs merge=lfs -text

Then I can push to remote.

  • Your statement seems to be correct: using union merge on `.gitattributes` should get you the right result. Given that you can specify union merge for a file in `.gitattributes`, you should be able to modify `.gitattributes` to request a union merge. What, then, is your question? – torek Sep 08 '17 at 22:37
  • I have tried putting the following into .gitattributes, ".gitattributes merge=union" It did not work – Koen Bouwmans Sep 09 '17 at 13:06
  • I'm not an expert on p4, but how come the conflict was not signaled? Aren't you using any Xtheirs option – max630 Sep 09 '17 at 14:58
  • It may be difficult to do but if you can construct a [mcve], that would enable others to help you out. – torek Sep 09 '17 at 18:39

1 Answers1

0

The following works

git show origin/master:.gitattributes > ./.gitattributes.theirs touch blankFile git merge-file --union .gitattributes blankFile .gitattributes.theirs

if you do not want to overrride .gitattributes you can do

git merge-file -p --union .gitattributes blankFile .gitattributes.theirs > .gitattributes.new