I was wondering if someone had a trick to color the ouput of a merge or rebase when there is a conflict. I want to color specially the line with the filename, for example the second line here :
Auto-merging CMakeLists.txt
CONFLICT (content): Merge conflict in CMakeLists.txt
Failed to merge in the changes.
Thanks
EDIT :
Using git alias and a bash function I can write this :
color-merge = "!f() { git merge --no-commit --stat $1| egrep --color 'CONFLICT .*|$'; }; f"
This will color all the conflict lines but :
So I'm looking for something more powerful.
Cheers
Handling Conflicts When Rebasing When applying commits to a new base state, it is possible that the new base has made changes that are conflicting with the changes you are trying to apply. For example, if on main someone edited the same file and line you did on your branch. The same thing happens when merging.
Another option might be to create a git alias. This is preferable to me because it keeps keep git-specific customizations together instead of floating elsewhere in an unrelated .profile
file somewhere.
Adding something like this to your ~/.gitconfig
or the local git project's .git/config
should also work:
[alias]
color-merge = "!f() { git merge $@ | egrep --color 'CONFLICT .*|$' ; }; f"
Invoke it like so: git color-merge branch --option1
Note that your shell's GREP_COLOR
environment variable will control the color used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With