修改 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
- Git Basics Tagging
- git tag <tagname> [<commit>]
- git tag -d <tag name>
- git tag
- git tag -l
查閱指定 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;
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è)試通過
- 推送到線上