git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: commiting while the current version is in conflict

From
Jakub Narebski <jnareb@gmail.com>
Date
Oct 16, 2008, 23:42 UTC
Message-ID
<m3ljwojeeu.fsf@localhost.localdomain>
In-Reply-To
<2d460de70810161510ha220593g4615a55b2c3e3b25@mail.gmail.com>
"Richard Hartmann" <richih.mailinglist@gmail.com> writes:
Show 10 quoted lines
> I fooled around with git a liitle bit and noticed something
> rather strange. I merged two branches, creating a conflict
> on purpose. When I then did a
> 
>  git commit -a
> 
> all changes were submitted. Of course, I now have a
> file with the conflict markers inlined in my repository. Not
> a good thing, imo. Is there a way to make git block all
> conflicting versions?
The default pre-commit hook shipped with git includes this check.  
All you have to do is enable it: it has to be named 'pre-commit' and
it has to be exacutable.  In older git version you would do:
  $ chmod a+x .git/hooks/pre-commit
while in never versions it would be
  $ mv .git/hooks/pre-commit.sample .git/hooks/pre-commit
 
> Also, I would be interested in the design decissions
> behind the current behaviour. Any pointers?
It is a git policy that it ships with all hooks disabled.

P.S. You can always bypass pre-commit hook (for example if comitting AsciiDoc files, which may include something that looks like conflict markers, or if you are committing test which includes conflicted file as one of test vectors), by using `--no-verify' option to git-commit.

-- 
Jakub Narebski
Poland
ShadeHawk on #git
Previous: Richard HartmannNext: Richard Hartmann
Message 9 of 10 in “commiting while the current version is in conflict”
  1. Richard HartmannOct 16, 2008
  2. Miklos VajnaOct 16, 2008
  3. Shawn O. PearceOct 16, 2008
  4. Richard HartmannOct 16, 2008
  5. Avery PennarunOct 17, 2008
  6. Richard HartmannOct 16, 2008
  7. Shawn O. PearceOct 16, 2008
  8. Richard HartmannOct 16, 2008
  9. Jakub NarebskiOct 16, 2008
  10. Richard HartmannOct 17, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.