git merge stategy for deploy.rb
By kenglish
My problem is that I have multiple git branch of a rails project and in each branch, I want to maintain a different value the branch setting my deploy.rb. For example:
In branch v1.0.0-stable
set :branch, "v1.0.0-stable"
In branch, I want v1.0.1-stable
set :branch, "v1.0.1-stable"
In the master branch, I want no value.
The problem is that I often merge from v1.0.1-stable into the master branch and this overwrites the deploy.rb. This can be frustrating because every time I need to remember to remove that “set :branch” line from the deploy.rb. If I forget and deploy from the master, it will deploy version “v1.0.1-stable” instead of master. This always results in my wondering “Why didn’t the deploy work? Why aren’t my changes on the site?”
The only way that I could find to prevent this is to adding a line my gitattributes file.
In .git/info/attributes, I added:
deploy.rb merge="ours"
Ours is a merge strategy and this tells git always apply
ours
This resolves any number of heads, but the result of the merge is
always the current branch head. It is meant to be used to
supersede old development history of side branches.
Note:
If you Google git merge the first 5 pages of results are the man page for the git-merge command. Why does everyone feel the need to replicate the man page all over the internet. Seriously! If what I needed was in the man page, I wouldn’t be using Google!
git 


December 19th, 2008