修改 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 的时间
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 参数会打印出所显示的 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 开发者
git push --tags prod-wbs +<commit>:<dst>
将本地 <commit> 连同所打 tags 一同推送到远程 prod-wbs 的 <dst>:
--tags 标明将所打 tags 一同推送; refs/tags 目录下记载了所有的 tags;branch,tag 都是一种 commit-ish;
由于增加了推送人员的负担,故不在本地打tag,这里仅用于学习说明;
通过 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
设计图:
https://en.wikipedia.org/wiki/Deployment_environment
Set "denyNonFastforwards" to false
设置 denyNonFastforwards = true
更安全;在特殊情景情况下,为能强行推送,则可以设为 false;
cd example.git/
vim config
[receive]
denyNonFastforwards = false
error: denying non-fast-forward refs/heads/master (you should pull first)
推送步骤
- 开发在本机测试通过
- 推送到线上