0

I'm trying to set a directory as binary (a directory, not subfiles of the directory).

I try this in .gitignore :

DIRNAME binary

The gaol is to specify to git that the directory as to be treated as a "binary file"

To clearly explain :

  • My directory contain a set of files and subdirectories that can be read (all files and subdirectories in one time) by a specific program, it's like a Excel file (file.xlsx), an Excel contain multiple files and subdirectories, compressed with an xlsx extension, readable only by Microsoft Excel.

  • In parallel

    • for my case : folder = binary file (all subfolder and files is needed to be readable)
    • for Excel case : file.xlsx = binary file

It is possible to specify to Git that my directory is like a binary file ?

The goal, in parallel (when git merge) :

  • for my case : Treat the directory as binary to execute diff with specific tool (that need the directory and its all contents)
  • for Excel case : Treat file as binary to execute diff with Excel

I don't know if I was explain my problem clearly but it's not simple to describe...

3
  • DIRNAME binary doesn't look like a valid glob? --- Also are you looking for git lfs? Commented Jan 13, 2021 at 21:31
  • Thank's for your reply, I never use lfs and I don't see how can I use it in my case, because the directory DIRNAME must be manage like a file, as I explain. If I one of subfile modified on a second branch, when I merge it into my first branch I need to open the directory (from each branch) with my specific diff and merge tool. And if the folder is not represented as one file, git merge open each files where the modification has realized, but I must use the directory and not each files one by one, to be open with my specific diff and merge tool Commented Jan 13, 2021 at 22:03
  • @torek any ideas? I'm kinda lost Commented Jan 13, 2021 at 22:43

1 Answer 1

1

This isn't possible. .gitattributes specifically doesn't match directories, only files, so there's literally no way to handle directories using it.

If you want to merge individual files in the directory in a given way, you can set a pattern like dirname/** to match all the files recursively under a directory and then apply a custom merge driver for each individual file. However, you can't merge that file based on the contents of other files also in that directory.

In general, binary files usually aren't a good fit for a repository, although there are exceptions. You may have more luck turning it into a single text file which you can then merge if that's supported. Otherwise, you may want to ask a new question about how to best handle storing your particular type of data for use with a project.

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

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.