How to automatically detect if there is a Git commit or rebase, something like "<<<<< HEAD"?

I recently made a dumb mistake by committing a code containing git redirect messages, something like <<<<< HEAD.

I believe this happened because I git add . ; git rebase --continuedid not check if the file contains these messages.

I would like to know if it is anyway to prevent this? I mean, usually Git warns you when merging with such messages. But after you, do git add .I believe Git treats them as part of my code?

I tested a well-known tool called overcommit ( bridage / overcommit ) but there seems to be no such check.

Edit: in overcommit, here is this PreCommit / MergeConflicts , which only checks my manual for git commit, but if this happens during rebase, it won’t trigger.

I hope I find a real way to discover this.

+4
source share
2 answers

The icon is <<<<< HEADadded to the file when a conflict occurs.

Therefore, when you restore a branch and git finds some conflicting changes, it tags it with tags

<<<<<<< HEAD 
conflicting changes in HEAD 
============ 
conflicting changes in current commit 
>>>>>>> commit SHA1

, , git bash , . , mergetool, kdiff3. git rebase --continue, rebase.

enter image description here

  • git bash 1 master
  • git , .
  • git rebase , rebase .

, .

enter image description here

, , , , , git git rebase --continue .

<<<<<<< HEAD rebase.

, - , kdiff3. http://jebaird.com/2013/07/08/setting-up-kdiff3-as-the-default-merge-tool-for-git-on-windows.html

, kdiff3, git mergetool bash, kdiff3, , , . kdiff3 .

,

+2

? . , , , nocommit

0

Source: https://habr.com/ru/post/1671225/


All Articles