how to handle gitting of binaries, e.g. .mo files

ε祈祈猫儿з 提交于 2019-12-01 00:01:50
VonC

You could add a custom merge driver in a gitattributes file (see this SO question), only for the *.mo files and only in the relevant directories.

echo *.mo merge=keepTheir > dirWithMoFiles\.gitattributes
git config merge.keepTheir.name "always keep theirduring merge"
git config merge.keepTheir.driver "keepTheir.sh %O %A %B"

With keepTheir.sh as:

mv -f $3 $2
exit 0

Well the best idea is not to keep generated files (such as .mo files) under version control.

If you still want to have them in Git, use standard ways to resolve conflicts.

For example you can get either version of conflicting file:

git checkout --theirs -- dir/file.mo
git checkout --ours -- dir/file.mo

Or use git mergetool which will provide you both versions of conflicting file.

equivalent8

basically this concept was nicely explain here How do I tell git to always select my local version for conflicted merges on a specific file?

and here is a bash script simplifying the steps described there https://github.com/equivalent/git_to_svn_behavior-

(steps how to run in Readme)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!