From: Jakub Narebski <jnareb@gmail.com>
To: William Tanksley <wtanksleyjr+git@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Can git be stopped from inserting conflict markers during a merge?
Date: Sat, 08 Mar 2008 13:03:18 -0800 (PST) [thread overview]
Message-ID: <m3ve3xexnw.fsf@localhost.localdomain> (raw)
In-Reply-To: <loom.20080308T174918-559@post.gmane.org>
William Tanksley <wtanksleyjr+git@gmail.com> writes:
> I started using Mercurial a while ago, and I'd like to move up to
> git (for a number of reasons). The one thing that's stopping me is
> that (having recently escaped Subversion and CVS) I'm now used to
> NOT having to worry about conflict markers being shoved into
> files. To put it simply, I really like how Mercurial does that one
> thing.
>
> So, given the Git is probably the ultimate in configurability, what
> do I need to do to make it not insert merge markers?
First, if you simply enable installed by default (but not enabled)
pre-commit hook, by making it executable:
$ chmod a+x .git/hooks/pre-commit
it would detect merge markers in changes, and would prevent committing
with "unresolved merge conflict (line <n>)" message[*1*].
You can of course bypass pre-comit and commit-msg hooks with
--no-verify option, for example if committing merge test case, or if
hooks misdetects asciidoc markup for merge conflict markers.
Second, you can change default file-level (file contents) merge driver
to the one used for binary files; it would leave 'ours' version on
disk instead of merged file with merge conflict markers[*2*][*3*]
Simply add the following to the repository configuration in
'.git/config', or to global (user) git configuration in
'~/.gitconfig', or if you are admin you can even add it to system wide
git config '/etc/gitconfig' although I wouldn't recommend last one:
[merge]
default = binary
Or if you prefer scripted solution,
$ git config merge.default binary
(this would change repository config: read git-config(1)).
Footnotes:
==========
[*1*] It also detects "trailing whitespace" and "indent SP followed by
a TAB" errors; whitespace errors can be detected by git-commit
iself with --cleanup=<mode> option and/or gitattributes.
[*2*] Sample session below:
[master!test]$ git version
git version 1.5.4.2
[master!test]$ git show master:foo
HELLO
hello
[master!test]$ git show side:foo
HELLO
hello side
[master!test]$ git merge side
Auto-merged foo # [*4*]
CONFLICT (content): Merge conflict in foo
Automatic merge failed; fix conflicts and then commit the result.
[master!test]$ cat foo
HELLO
<<<<<<< HEAD:foo
hello
=======
hello side
>>>>>>> side:foo
[master!test]$ git reset --hard HEAD
[master!test]$ git config merge.default binary
[master!test]$ git merge side
Auto-merged foo
CONFLICT (content): Merge conflict in foo
Automatic merge failed; fix conflicts and then commit the result.
[master!test]$ cat foo
HELLO
hello
[*3*] If you want to do this only for some files, you can use
gitattributes feature.
[*4*] I wonder about this "Auto-merged foo" message...
--
Jakub Narebski
Poland
ShadeHawk on #git
prev parent reply other threads:[~2008-03-08 21:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-08 17:55 Can git be stopped from inserting conflict markers during a merge? William Tanksley
2008-03-08 20:51 ` Linus Torvalds
2008-03-08 22:24 ` Martin Langhoff
2008-03-08 21:03 ` Jakub Narebski [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3ve3xexnw.fsf@localhost.localdomain \
--to=jnareb@gmail.com \
--cc=git@vger.kernel.org \
--cc=wtanksleyjr+git@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).