19

I maintain a fork of a repo.

That repo which has been tracking a binary file (which is a sqlite3 file).

Every time I pull from that repo, I experience merge conflict due to that binary file.
What is the right way to solve this kind of merge conflict?

What is the right way to manage binary files (like this sqlite3 *.db file) in git?

2 Answers 2

12

You could define a custom merge driver specifying to always "keep theirs" (copy the version you are pulling) on top of your current version.

.gitattributes

mysqlite3.db merge=keepTheir

(That being said, remember binaries aren't always best managed with Git, especially if they are modified often)

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

6 Comments

I cant find .gitattributes. Do I have to create a file in $GIT_DIR/info/attributes?
@shadyabhi: No, you have to create a file called .gitattributes in the parent directory of the things you want it to apply to (probably the top level of your projects), just like with a .gitignore. The $GIT_DIR/info/attributes would only apply to your specific clone of the repo, not others, since it's obviously untracked.
@shadyabhi: The question stackoverflow.com/questions/1910444/… gives you a more detailed example.
@Jefromi Do files like .gitignore & .gitattributes are added using "$git add"? Also, I am new to all this, can you please guide to a nice documentation. Most tutorials I saw didnt give nice examples of merging and solving conflicts.
@shadyabhi: Yes, that's the point; you track them in your repository so that all clones of the repository ignore the same things (e.g. build objects) and use the same attributes (e.g. that file is definitely text, merge this file that way). For documentation, I will always recommend the man pages. In this case, man gitattributes.
|
3

I've released a tool that does what you're asking for. It uses a custom diff driver leveraging the sqlite projects tool 'sqldiff', UUIDs as primary keys, and leaves off the sqlite rowid. It is still in alpha so feedback is appreciated.

https://github.com/cannadayr/git-sqlite

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.