fat*_*oku 5 git merge git-merge branching-strategy
这个问题不是特定于iOS的,但为了清楚起见,我在此处包含了实际用例
我运行一个名为iOS的项目Foobar,显然是在版本控制之下.在iOS项目环境中的项目文件中,有一个名为Foobar-Info.plistXML文件,它存储有关项目的有趣信息,例如版本和我所构建的构建数量.
每次我构建项目时,我都会将存储在此文件中的构建计数递增,如下所示:
...
<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>
...
Run Code Online (Sandbox Code Playgroud)
其中'0.0.4-release'是git-flow分支名称,2203是内部版本号.这是在CFBundleVersion现场使用的,所以对我来说,构建来自哪里是非常明显的.
想象一下,在另一个分支中,自发布以来我已经取得了很多进展,并且相同的字段看起来像:
...
<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>
...
Run Code Online (Sandbox Code Playgroud)
假设我完成了发布,它已合并到主线develop分支中.
问题
为了获得发布分支中的最新更改,我想将功能分支重新绑定到develop.
当发生这种情况时,Foobar-Info.plist将在rebase进程中的每次提交时引发冲突.这是因为每次提交都会增加构建号; 我必须通过选择手动指定具有最新版本的行来手动合并.请注意,3向差异的基本版本也会有所不同.
<string>2000</string> // Base
<string>2754</string> // Local ** always pick this one; it's the latest
<string>2203</string> // Remote
Run Code Online (Sandbox Code Playgroud)
我怎么能告诉git对于一个特定的文件,Foobar-Info.plist我希望它通过最新的更改来解决我的冲突?
编辑:该文件必须保持在源代码管理下.我想保留BuildCount它,因为它是我项目中努力的一个很好的指示,我想保留它!我知道这个数字只表示完成的MINIMUM数量,但这对我来说已经足够了.
我意识到这是一个迟到的答案,但如果我理解你的问题,你正在寻找的是一个.gitattributes文件。
您可以使用文件的相对路径为特定文件或文件夹指定合并策略.gitattributes,如下所示:
* text=auto
path/to/your/file.plist merge=union
Run Code Online (Sandbox Code Playgroud)