This question is not iOS-specific, but I'm including the actual use case here for clarity
I run an iOS project called Foobar
, obviously kept under version control.
Amongst the project files in the iOS project environment there's something called Foobar-Info.plist
, an XML file which stores interesting information about the project, like versions and the number of builds I've made.
Every time I build the project, I increment the build count stored in to this file like so:
...
<key>BuildCount</key>
<string>2203</string>
<key>CFBundleShortVersionString</key>
<string>0.0.4</string>
<key>CFBundleVersion</key>
<string>0.0.4-release/0.0.4.2203</string>
...
where '0.0.4-release' is a git-flow branch name, and 2203 is a build number. This is used in the CFBundleVersion
field, so that it's really obvious to me where the build came from.
Imagine in another branch, I've made a lot of progress since the release and the same fields look like:
...
<key>BuildCount</key>
<string>2754</string>
<key>CFBundleShortVersionString</key>
<string>0.0.4</string>
<key>CFBundleVersion</key>
<string>0.0.4-feature/add-quux-and-baz.2754</string>
...
Let's say I'm done with release, and it's merged into the mainline develop
branch.
The problem
In order to get the latest changes made in the release branch, I want to rebase the feature branch onto develop
.
when this happens, Foobar-Info.plist
will cause a conflict at every commit in the rebase process. This is because the build numbers will have incremented for every commit; I must manually merge by choosing the lines manually specify the lines with the latest version. Note that the base version of the 3-way diff will also be different.
<string>2000</string> // Base
<string>2754</string> // Local ** always pick this one; it's the latest
<string>2203</string> // Remote
How can I tell Git that for one specific file, Foobar-Info.plist
, I want it to resolve my conflicts for me by taking the latest change?
The file must be kept under source control. I want to keep the BuildCount
because it's a cool indication of effort put into my project and I want to keep it! I know that the figure only indicates the minimum number of builds done, but that'll be good enough for me.
develop
has commits from other features, which has a greater build number from the branch being rebased. – Gremlin