一.服务端配置hooks:
1.<project>.git 目录下面创建custom_hooks
2. custom_hooks目录下面创建脚本文件,例如:pre-receive文件
并且可执行权限设置为777(或者设置其为git所有)
3.pre-receive文件中写入代码,exit 1会阻止提交;
二.客户端配置hooks:
1.项目目录下隐藏文件.git 目录下创建hooks文件夹
2.将脚本文件添加到hooks文件夹下面
三.git文档:
https://git-scm.com/book/zh/v2/自定义-Git-Git-钩子
四.Git中文开发手册:
http://www.php.cn/manual/view/34963.html
1.暂存:
git add -A
2.缓存:
git stash
3取消缓存:
git stash pop
4.回退commit
git reset --soft 1
五.git获取日志信息:
1.git log -n 30
获取最后30条log记录
2.git log -n 5 --pretty=format:“%cd”
取log中的某些信息,format后面定制化:
%H 提交对象(commit)的完整哈希字串
%h 提交对象的简短哈希字串
%T 树对象(tree)的完整哈希字串
%t 树对象的简短哈希字串
%P 父对象(parent)的完整哈希字串
%p 父对象的简短哈希字串
%an 作者(author)的名字
%ae 作者的电子邮件地址
%ad 作者修订日期(可以用 -date= 选项定制格式)
%ar 作者修订日期,按多久以前的方式显示
%cn 提交者(committer)的名字
%ce 提交者的电子邮件地址
%cd 提交日期
%cr 提交日期,按多久以前的方式显示
%s 提交说明
3.查看本地的操作记录:
git reflog
4.回到98abc5a对应的那次commit:
git reset --hard 98abc5a
5.git强制push:(master 分支名)
git push origin master -f
六.git 查看分支之间的关系:
1.查看所有:
git log --graph --decorate --oneline --simplify-by-decoration --all
2.查看指定分支:
git log --graph --decorate --oneline --simplify-by-decoration A分支 B分支 C分支