如何找出git push的内容

时间:2017-02-10 18:31:04

标签: git

如果有办法看到给定推送中包含的确切内容,我就会徘徊。我正在寻找提交和推送元数据之类的东西。

1 个答案:

答案 0 :(得分:1)

是的,您可以使用钩子通过git hooks找出提交内容的内容。您可以使用pre-receivepost-receive挂钩

<强> pre-receive/post-receive

#!/bin/sh


# assuming this is not teh first commit. it it is you will have to add extra lines of code
# Check to see if we have updated the given file

# the content can be grabbed using this command: 
if [ $(git diff-tree -r --name-only HEAD^1)  ];

    # 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  " 
    echo "                                         "
    echo "${default}"