当前位置: 动力学知识库 > 问答 > 编程问答 >

qt - Git: avoiding frequently-changed lines

问题描述:

This question already has an answer here:

  • How to tell git to ignore individual lines, i.e. gitignore for specific lines of code [duplicate]

    2 answers

网友答案:

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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: