There is an xml file in my project: mainWindow.ui. It is Qt Designer file for the GUI. For every single icon and other resource, there is a line like:
<iconset resource="../build/resources.qrc">
The problem is that resources.qrc is a configured file whose location depends on the particular user's build directory (which tends to be different for everyone depending on their preferences, e.g.
<iconset resource="../../build/resources.qrc">
This leads to an enfuriating battle between developers who edit mainWindow.ui, because they change about 50 lines every time, and this means a long and tedious manual merge for this file every single time a merge request happens.
Without making mainWindow.ui a configured file as well, can I tell git not to allow changes to those lines, or can I tell Qt Designer to fix that location? How can I avoid this situation?
You could set up a .gitattributes
file that can specifify that all merge conflicts are resolved using our
settings:
mainWindow.ui merge=ours
This will stop the mainWindow.ui
from being overwritten by merges. Instead of conflicting, this will silently resolve the merge by accepting the current state of the file. This can be good if the developers have their own branches with settings in. If they work directly on master it will be less good, since they will then push their own settings.
Alternatively, and probably better in your case, each developer could force git to ignore changes to mainWindow.ui
:
git update-index --skip-worktree mainWindow.ui
This is quite confusing, but it makes Git disregard changes in the file when pushing but Git still tries to preserve the changes in the local file when pulling, only updating it if the remote is updated. An overview can be found here.