I'm running into an issue where branch merging fails because Crashlytics binaries are changing. I added Crashlytics to the gitignore, but now the framework doesn't show up if I checkout branches anymore.
Is there a way to deal with the merge conflicts or a way to tell git to ignore changes to the file, but keep the file itself?
If you want the file in a fresh clone, or after cleaning a git repository it needs to be tracked by git.
Binary files are not pretty to merge. From you question it sounds like there isn't anything to merge, but the decision is just which file to keep. One thing you could do is define custom automatic merge behavior for these binaries via .gitattributes and .git/config settings:
Add the following to your .gitattributes (or create a new file with that content in the root of your git repository)
path/to/file merge=nomerge
and place the following into a git configuration file (.git/config, or ~/.gitconfig)
[merge "nomerge"]
name = keep current version
driver = true
This instructs git just ignore the conflict and keep the file from the branch into which you are merging.
The driver = true
specifies an external program to use for merging. In this case the program is true
which should be available on any unix like system and does nothing successfully.
See the gitattributes manpage section on Defining a custom merge driver on ways to add real custom logic if you need something smarter.
On could do really complex things like always keeping the higher version of the file, if there is any version indicator in file for example.
You should git add
the .gitattributes file to the repository. The actual merge driver definition can't be stored in a way that new clones get it automatically out ouf the box. So you need to add this manually into each clone or in the per user config on every computer where you need it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With