4

it's possible to create an git alias to colorize the output, in error case, of git push command?

I have one that works to log, but i can't modify it to works with push.

git log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%C(62)\\ [%cn]\\ %ce" --decorate

example of error message:

"error: failed to push some refs to 'https://github.com/user/projectname.git'"

1
  • According to this question it's not possible, but it's almost 2 years old. You can check the Git's source code. Commented Apr 25, 2016 at 13:35

1 Answer 1

3

What should the push print?

push printout the result of the "pushed" code to the server. You can have server side hook which sends out colored messages to the user.

pre-receive hook

#!/bin/sh

# Output colors
red='\033[0;31m';
green='\033[0;32m';
yellow='\033[0;33m';
default='\033[0;m';

# personal touch :-)
echo "${red}"
echo "                                         "
echo "                   |ZZzzz                "
echo "                   |                     "
echo "                   |                     "
echo "      |ZZzzz      /^\            |ZZzzz  "
echo "      |          |~~~|           |       "
echo "      |        |-     -|        / \      "
echo "     /^\       |[]+    |       |^^^|     "
echo "  |^^^^^^^|    |    +[]|       |   |     "
echo "  |    +[]|/\/\/\/\^/\/\/\/\/|^^^^^^^|   "
echo "  |+[]+   |~~~~~~~~~~~~~~~~~~|    +[]|   "
echo "  |       |  []   /^\   []   |+[]+   |   "
echo "  |   +[]+|  []  || ||  []   |   +[]+|   "
echo "  |[]+    |      || ||       |[]+    |   "
echo "  |_______|------------------|_______|   "
echo "                                         "
echo "                                         "
echo "      ${green}You have just committed code ${red}  " 
echo "      Your code ${yellow}is bad.!!!      "
echo "      ${red} Do not ever commit again    "
echo "                                         "
echo "${default}"

Sign up to request clarification or add additional context in comments.

6 Comments

He probably wants to have error messages highlighted somehow.
I have posted a full working sample. Im using it as part of my repo hooks.
But the hook doesn't change the behavior of Git, it's just something executed in addition, it doesn't change what or how Git is printing to the console. Or does it receive the error message as an argument so you can print it again (so it will be printed twice)? Or I don't understand what you mean.
Cool so you have the answer :-).
No one can miss such an error message ...... Trust me. Im updating the ascii are once in awhile to track attention
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.