0

I'm trying to include all (data) files in LFS except if they have the .(r|R) or .(cpp|CPP) extension, but somehow both extensions end up in LFS too, and I'm unable the remove them from it. This is what I tried so far:

/**/data/** filter=lfs diff=lfs merge=lfs -text
/**/data/**.[rR] -filter=lfs -diff=lfs -merge=lfs text
/**/data/**.[cC][pP][pP] -filter=lfs -diff=lfs -merge=lfs text

and

/**/data/** filter=lfs diff=lfs merge=lfs -text
/**/data/**.[rR] !filter !diff !merge text
/**/data/**.[cC][pP][pP] !filter !diff !merge text

After that I do:

find user-*/data -name "*.R" -print0 | xargs -0 -i echo git lfs untrack "'{}'" | bash
find user-*/data -name "*.R" -print0 | xargs -0 -i echo git rm --cached "'{}'" | bash
find user-*/data -name "*.R" -print0 | xargs -0 -i echo git add "'{}'" | bash

What am I doing wrong?

git check-attr -a for one of the files I like to exclude from LFS looks like this:

# git check-attr -a 'user-004/data/get-data.R'
user-004/data/get-data.R: diff: unset
user-004/data/get-data.R: merge: unset
user-004/data/get-data.R: text: set
user-004/data/get-data.R: filter: unset

If I understand it correctly that's good, but the file still is in LFS and I don't know how to move it to regular versioning.

3
  • Use git check-attr to check attributes. find . | xargs git check-attr -a Commented Jan 17 at 12:57
  • 1
    I added some output to my question Commented Jan 17 at 13:18
  • May be git lfs fetch + git lfs checkout? Or explicitly use git lfs smudge: git lfs smudge < user-004/data/get-data.R > tmp && mv tmp user-004/data/get-data.R Commented Jan 17 at 13:28

2 Answers 2

0

The issue probably is that files already tracked by Git LFS won't change just by updating .gitattributes.

  • Update your .gitattributes to exclude .R and .cpp files from LFS.
  • Remove the files from the index to stop LFS tracking
git rm --cached path/to/your/files
  • Re-add the files so Git tracks them normally:
git add path/to/your/files
  • Commit the changes to apply the updates.

This is the same logic as applied here : Files are still (not) in GIT LFS after changing .gitattributes

Sign up to request clarification or add additional context in comments.

1 Comment

That's exactly what I did with the find commands, but then there's nothing to commit :-(
0

The issue seems to be fixed now. What it read was that "multiple recursive expressions within the path are not supported" (**); see.

And the other thing that seemed to be an issue is that I needed both /*/data/**.[rR] and /*/data/**/*.[rR] to match all files.

My .gitattributes file looks something like this now:

/*/data/** filter=lfs diff=lfs merge=lfs -text

/*/data/**.[rR] !filter !merge !diff !text
/*/data/**.[cC][pP][pP] !filter !merge !diff !text

/*/data/**/*.[rR] !text !filter !merge !diff
/*/data/**/*.[cC][pP][pP] !text !filter !merge !diff

After that I run:

git lfs migrate import --everything --fixup;

git lfs migrate export --everything --include '/*/data/**.[rR]';
git lfs migrate export --everything --include '/*/data/**.[cC][pP][pP]';
git lfs migrate export --everything --include '/*/data/**/*.[rR]';
git lfs migrate export --everything --include '/*/data/**/*.[cC][pP][pP]';

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.