tags:

views:

763

answers:

3

I am using Git to track my documentation latex source. I want to keep the master branch full of documents that are suitable for end user release, so when someone needs something, i can just switch to the master branch, compile and hand out the document.

I make new branches when a manual needs a major update. But, when the manual is approved, it needs to get merged back into the master. When merging from branch into master, I would like to pass some command to Git to say, "forget the merging, just use the the file from branch to overwrite the file in master." Is there a way to do this? Specifically, I want to avoid opening up a merge tool every time. Thanks in advance.

+3  A: 

--strategy=ours

http://www.kernel.org/pub/software/scm/git/docs/git-merge.html

Robert
From here: http://stackoverflow.com/questions/366860/when-would-you-use-the-different-git-merge-strategies, this says: Ours == I want to pull in another head, but throw away all of the changes that head introduces.So is opposite of what OP wanted.
Amala
+1  A: 

I believe you can do this with the 'ours' merge strategy:

git checkout branch
git merge -s ours master

But this doesn't do exactly what you want: it override the contents of the current working branch branch and what you want is to get the same contents onto master. What you really want is a merge strategy theirs, and for that I point you at this similar question for a way to do it. In practice what it boils down to is resetting master to point at branch.

quark
+1  A: 

In version 1.7.1 of Git, you can use "-Xtheirs" to merge in the branch itself.

For example, if you start in your master branch, starting in master

git checkout -b editBranch
-- edit your files --
git add .
git commit -m "Updated the files"
git checkout master
git merge -Xtheirs editBranch

Another way that I've seen to do this based off this post is to do a hard reset off the editBranch. For example:

git checkout -b editBranch
-- edit your files --
git add .
git commit -m "Updated the files"
git checkout master
git reset --hard editBranch

I think this second way might be the better play, but I haven't had a chance to play around with it enough yet.

anotherAlan
thanks. I'll have to update git at home, and check this out. Much appreciated.
Mica