version control - Prevent merge on master branch for a type of file - Git -
i have git repo release branch ("master") , other branches develop purposes.
being embedded project, there .tbl files generated or modified on every compilation. need keep tbl files in master branch not modified (unless there new release) , therefore prevent merging other branches modifying tbl files.
i tried declaring tbl files binary or using *.tbl merge=ours
specified in https://git-scm.com/docs/git-merge work in case of conflict.
has ever run across similar situation?
git has no merge strategy case.
short of writing own merge strategy—git merge -s arenalor
invoke git-merge-arenalor
, , you'd have write command whatever you wanted—there is, observed, no way git normal three-way merge on files keep particular version of particular set of files in place.
fundamentally, merge strategies following:
- identify merge-base commit. let's call commit b convenience. b has bunch of files saved snapshots; here, other 2 branches diverge.
- diff merge base against each branch tip, find files changed in branches. illustration, it's simplest call 2 branch tips l , r, left , right, or local , remote, or ours , theirs (there no l in word "ours" how git works usual recursive , resolve strategies).
- build new commit-to-make taking each file b (no change in either branch), l (file changed in our local/left-side branch), r (file changed in remote/right-side branch), or—if file changed in both of 2 branch-tip commits—by combining changes.
the *.tbl merge=ours
option in .gitattributes
file affects only step 3, , only if file changed in both branch-tip commits. is, merge driver run if git has combine changes. doesn't matter whether changes have conflicts; matters both l , r have changed file f respect in merge base commit b.
these decisions made merge strategy, though, if write own, can make own decisions. note -s ours
strategy quite different: instead of doing above 3 steps, 1 step:
- take files l. don't need find b, or @ contents of r. keep whatever's in index right , make merge commit parent 1 = l , parent 2 = r.
that want *.tbl
files, wrong other files, it's not suitable here.
Comments
Post a Comment