Xcode change storyboard's frame value automatically cause git merge conflict all the time. How to solve it?

北慕城南 提交于 2019-12-04 06:29:39

You could avoid checking in such modified value by convincing Git that the file content has not changed.

That is possible with a clean script which will be in charge of keeping only an integer value for x.
That script will be applied only to the .storyboard files (as described here), and will have to replace "254.xxx" by "254".

 sed -i 's/x=\"([0-9]+).*\"/x=\"\1\"/g'

The restoration of the file through that script is automated through a content filter driver, using a .gitattributes declaration.


(image from "Customizing Git - Git Attributes" from "Pro Git book"))

Once you declare that content filer driver in your local git config, it will automatically, on git commit, restore the file.
Or it will consider the file as unchanged on git diff/git status, even when XCode modified that value.

See a complete example in "Best practice - Git + Build automation - Keeping configs separate".

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