您的位置:首页 > 其它

git log

2015-11-30 19:39 295 查看
例子:
$ git log --pretty=format:"%h - %an, %ar : %s"
输出:ca82a6d - Scott Chacon, 11 months ago : changed the version number085bb3b - Scott Chacon, 11 months ago : removed unnecessary test codea11bef0 - Scott Chacon, 11 months ago : first commit
常用的格式占位符写法及其代表的意义:
# 下面参数定义列表'%H': commit hash'%h': 缩短的commit hash'%T': tree hash'%t': 缩短的 tree hash'%P': parent hashes'%p': 缩短的 parent hashes'%an': 作者名字'%aN': mailmap的作者名字 (.mailmap对应,详情参照git-shortlog(1)或者git-blame(1))'%ae': 作者邮箱'%aE': 作者邮箱 (.mailmap对应,详情参照git-shortlog(1)或者git-blame(1))'%ad': 日期 (--date= 制定的格式)'%aD': 日期, RFC2822格式'%ar': 日期, 相对格式(1 day ago)'%at': 日期, UNIX timestamp'%ai': 日期, ISO 8601 格式'%cn': 提交者名字'%cN': 提交者名字 (.mailmap对应,详情参照git-shortlog(1)或者git-blame(1))'%ce': 提交者 email'%cE': 提交者 email (.mailmap对应,详情参照git-shortlog(1)或者git-blame(1))'%cd': 提交日期 (--date= 制定的格式)'%cD': 提交日期, RFC2822格式'%cr': 提交日期, 相对格式(1 day ago)'%ct': 提交日期, UNIX timestamp'%ci': 提交日期, ISO 8601 格式'%d': ref名称'%e': encoding'%s': commit信息标题'%f': sanitized subject line, suitable for a filename'%b': commit信息内容'%N': commit notes'%gD': reflog selector, e.g., refs/stash@{1}'%gd': shortened reflog selector, e.g., stash@{1}'%gs': reflog subject'%Cred': 切换到红色'%Cgreen': 切换到绿色'%Cblue': 切换到蓝色'%Creset': 重设颜色'%C(...)': 制定颜色, as described in color.branch.* config option'%m': left, right or boundary mark'%n': 换行'%%': a raw %'%x00': print a byte from a hex code'%w([[,[,]]])': switch line wrapping, like the -w option of git-shortlog(1).
其他常用的选项及其释义:
选项 说明-p 按补丁格式显示每个更新之间的差异。--stat 显示每次更新的文件修改统计信息。--shortstat 只显示 --stat 中最后的行数修改添加移除统计。--name-only 仅在提交信息后显示已修改的文件清单。--name-status 显示新增、修改、删除的文件清单。--abbrev-commit 仅显示 SHA-1 的前几个字符,而非所有的 40 个字符。--relative-date 使用较短的相对时间显示(比如,“2 weeks ago”)。--graph 显示 ASCII 图形表示的分支合并历史。--pretty 使用其他格式显示历史提交信息。可用的选项包括 oneline,short,full,fuller 和 format(后跟指定格式)。
其他常用的类似选项:
选项 说明-(n)	仅显示最近的 n 条提交--since, --after 仅显示指定时间之后的提交。--until, --before 仅显示指定时间之前的提交。--author 仅显示指定作者相关的提交。--committer 仅显示指定提交者相关的提交。
后面的例子:如果要查看 Git 仓库中,2008 年 10 月期间,Junio Hamano 提交的但未合并的测试脚本(位于项目的 t/ 目录下的文件),可以用下面的查询命令:
$ git log --pretty="%h - %s" --author=gitster --since="2008-10-01" \   --before="2008-11-01" --no-merges -- t/5610e3b - Fix testcase failure when extended attributeacd3b9e - Enhance hold_lock_file_for_{update,append}()f563754 - demonstrate breakage of detached checkout wid1a43f2 - reset --hard/read-tree --reset -u: remove un51a94af - Fix "checkout --track -b newbranch" on detacb0ad11e - pull: allow "git pull origin $something:$cur
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  git 版本控制