Git 部署代碼 & 打標(biāo)簽

修改 sshd
  • /etc/ssh/sshd_config
    PermitUserEnvironment yes
  • service sshd restart

git clone ssh://192.168.99.236/~/wanpinghui/wbs.wph.git wbs.wph.236.readonly

http://stackoverflow.com/questions/8781240/a-way-to-restrict-git-branch-access

git: who pushed in post-receive hook
http://stackoverflow.com/questions/3762012/git-who-pushed-in-post-receive-hook

查閱指定 TAG 的時(shí)間
git show <tag name>
git log -1 --format=%ai <tag name>
git rev-parse release_20160710001021 | xargs git cat-file -p | gawk '/^author/ { print strftime(PROCINFO["strftime"], $(NF-1)) }'
  • git log --name-status --oneline --decorate | grep -e 'tag:'
    --decorate 參數(shù)會(huì)打印出所顯示的 tag 名,這樣才能 grep 出來;

  • 取得指定 <commit> 的 author name (user.name)
    git rev-parse <commit> | xargs git cat-file -p | gawk '/^author/ { print $2 }'
    git show [<commit>] --pretty=format:%an | head -n1
    不過沒什么用;

  • atlassian:jira 開發(fā)者

  • git push --tags prod-wbs +<commit>:<dst>
    將本地 <commit> 連同所打 tags 一同推送到遠(yuǎn)程 prod-wbs 的 <dst>:
    --tags 標(biāo)明將所打 tags 一同推送; refs/tags 目錄下記載了所有的 tags;

  • branch,tag 都是一種 commit-ish;

  • 由于增加了推送人員的負(fù)擔(dān),故不在本地打tag,這里僅用于學(xué)習(xí)說明;

通過 ssh 找到其 comment 用于 tag name;

githooks

https://www.atlassian.com/git/tutorials/git-hooks/server-side-hooks

#!/bin/sh
# 
# lock the myfeature branch for pushing
refname="$1"

if [[ $refname == "refs/heads/myfeature" ]]
then
    echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    echo "You cannot push to myfeature! It's locked"
    echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    exit 1
fi
exit 0

設(shè)計(jì)圖:
https://en.wikipedia.org/wiki/Deployment_environment

Set "denyNonFastforwards" to false

設(shè)置 denyNonFastforwards = true 更安全;在特殊情景情況下,為能強(qiáng)行推送,則可以設(shè)為 false;

cd example.git/
vim config
[receive]
        denyNonFastforwards = false

error: denying non-fast-forward refs/heads/master (you should pull first)

推送步驟
  • 開發(fā)在本機(jī)測(cè)試通過
  • 推送到線上
參考
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容