亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

GIT:我怎樣才能阻止foxtrot在我的'master'分支中合并?

GIT:我怎樣才能阻止foxtrot在我的'master'分支中合并?

Git
莫回無 2019-09-02 15:48:00
foxtrot合并是一種合并,其中'origin / master'作為第二個(或更晚的)父級合并,如下所示:提交'D'是foxtrot合并,因為'origin / master'是它的第二個父級。提交'D'是foxtrot合并,因為'origin / master'是它的第二個父級。注意此時來自“origin / master”的第一父歷史如何包含提交“B”。但是在我的git repo中,我需要所有涉及'origin / master'的合并來保持'origin / master'作為第一個父級。不幸的是,git在評估提交是否符合快進條件時并不關心父級。這會導致我的主分支上的第一個父歷史記錄有時會丟失曾經存在的提交(例如,輸出“git log --first-parent”)。以下是推送前面圖表中提交“D”時發生的情況:我怎樣才能防止這種推動? 推送foxtrot合并后,'origin / master'的第一父歷史不再包含提交'B'!我怎樣才能防止這種推動?推送foxtrot合并后,'origin / master'的第一父歷史不再包含提交'B'!顯然沒有提交或工作實際上丟失,只是在我的環境中我真的需要“git log --first-parent”作為一個穩定的提交累積記錄 - 如果你愿意,一種“一次寫入讀 - 許多“(WORM)數據庫。我有腳本和進程使用“git log --first-parent”來生成更改日志和發行說明,以及管理我的票證系統(JIRA)中的票證轉換。Foxtrot合并破壞了我的腳本!是否有某種預接收掛鉤我可以安裝在我的git存儲庫中以防止foxtrot合并被推送?ps使用http://bit-booster.com/graph.html生成此stackoverflow問題中的提交圖。
查看完整描述

3 回答

?
神不在的星期二

TA貢獻1963條經驗 獲得超6個贊

這是一個鉤子代碼,可以滿足您的要求:


pre-receive hook

#!/bin/sh


# Check to see if this is the first commit in the repository or not

if git rev-parse --verify HEAD >/dev/null 2>&1

then

    # We compare our changes against the previous commit

    against=HEAD^

else

    # Initial commit: diff against an empty tree object

    against=4b825dc642cb6eb9a060e54bf8d69288fbee4904

fi


# Redirect output to screen.

exec 1>&2


# Check to see if we have updated the master branch

if [ "$refname" eq "refs/heads/master" ];

then


    # 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}"

fi;


# set the exit code to 0 or 1 based upon your needs

# 0 = good to push

# 1 = exit without pushing.

exit 0;


查看完整回答
反對 回復 2019-09-02
  • 3 回答
  • 0 關注
  • 1412 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號