根底命令:

查看版本: git --version

log命令:

git log: 显示 commit 记录

log参数:

--pretty:

输入 log 的格局.
--pretty参数:
参数形容
emailuse email headers like From and Subject
formatspecify own format
fullall parts of commit messages
fullerlike full and includes dates
mediummost parts of messages
onelinecommit-ids and subject of messages
rawthe raw commits
shortfew headers and only subject of messages
pretty 自定义格局转义字符:

  如何查看到上面的参数,输出上面命令后 git log --pretty=format:%, 应用 tab 键这个老朋友显示进去(tab键性能,列出可选项,或者间接补充残缺惟一选项)
  这里比拟麻烦的是 这些参数有些是 %aD 这样的 第一次 tab 键显示进去的只是 第一个可选字符,如果你想晓得 %a 前面是否能够再填写其余,就在 %a 后 再持续 tab 列出来.

转义字符形容
%Hcommit hash
%h缩短的 commit hash
%Ttree hash
%t缩短的 tree hash
%Pparent hashes
%p缩短的 parent hashes
%an作者名字
%aNmailmap 的作者名字 (.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 格局
%dref 名称
%eencoding
%scommit 信息题目
%fsanitized subject line, suitable for a filename
%bcommit 信息内容
%Ncommit notes
%gDreflog selector, e.g., refs/stash@{1}
%gdshortened reflog selector, e.g., stash@{1}
%gsreflog subject
%Cred切换到红色
%Cgreen切换到绿色
%Cblue切换到蓝色
%Creset重设色彩
%C(...)制订色彩, as described in color.branch.* config option
%mleft, right or boundary mark
%n换行
%%a raw %
%x00print a byte from a hex code
%w([[,[,]]])switch line wrapping, like the -w option of git-shortlog(1)

-(n):

  只显示几条提交

--since,--after:

仅显示指定工夫之后的提交.
  例如, 最近两周的提交:
格局:

    git log --since=2.weeks

--until, --before:

仅显示指定工夫之前的提交.
  

--author:

仅显示指定作者相干的提交.
格局:
    git log --author=作者名称

--committer:

仅显示指定提交者相干的提交.
格局:
    git log --committer=提交者名称

--grep:

  选项搜寻提交阐明中的关键字。(请留神,如果要失去同时满足这两个选项搜寻条件的提交,就必须用--all-match 选项。)
例子格局:
  git log --grep=master --grep=feat --all-match

git log -- <path>:

  如果只关怀某些文件或者目录的历史提交,能够在 git log 选项的最初指定它们的门路。因为是放在最初地位上的选项,所以用两个短划线(--)隔开之前的选项和前面限定的路径名.
例子格局:
  git log --stat -- ./js/

--graph:

  显示 ASCII 图形示意的分支合并历史

-p:

  按补丁格局显示每个更新之间的差别

-stat:

  显示每次更新的文件批改统计信息

格式化日期

  格局: --date=参数

参数:

参数简写形容
defaultshow timestamp in the original timezone
formatcustom format
iso-strictshow timestamps in strict ISO 8601 format
iso8601isoshow timestamps in ISO 8601 format
localshow timestamps in local timezone
rawshow date in internal raw git format(%s %z)
relativeshow dates relative to the current time
rfc2822rfcshow timestamps in RFC 2822 format
shortshow only date but not time
unixshow date as a Unix epoch timestamp

  1. 失常状况下,输入的是规范工夫,然而咱们要本地工夫能够通过在上面的模式:
    格局: --date=参数-local

自定日期格局:

  格局: --date=format[-local]:自定义转义字符形容

  如何查看到上面的参数,输出上面命令后 git log --date=format:%, 应用 tab 键这个老朋友显示进去(tab键性能,列出可选项,或者间接补充残缺惟一选项)

转义字符形容:

转义字符形容
%aAbbreviated weekday name
%AFull weekday name
%bAbbreviated month name
%BFull month name
%cDate and time representation appropriate for locale
%dDay of month as decimal number (01 – 31)
%HHour in 24-hour format (00 – 23)
%IHour in 12-hour format (01 – 12)
%jDay of year as decimal number (001 – 366)
%mMonth as decimal number (01 – 12)
%MMinute as decimal number (00 – 59)
%pCurrent locale's A.M./P.M. indicator for 12-hour clock
%SSecond as decimal number (00 – 59)
%UWeek of year as decimal number, with Sunday as first day of week (00 – 53)
%wWeekday as decimal number (0 – 6; Sunday is 0)
%WWeek of year as decimal number, with Monday as first day of week (00 – 53)
%xDate representation for current locale
%XTime representation for current locale
%yYear without century, as decimal number (00 – 99)
%YYear with century, as decimal number
%z, %ZEither the time-zone name or time zone abbreviation, depending on registry settings; no characters if time zone is unknown
%%Percent sign

例如, 2020-01-01 10:00:00.
  规范工夫格局:

    --date=format:'%Y-%m-%d %H:%M:%S'
  本地工夫格局:
    --date=format-local:'%Y-%m-%d %H:%M:%S'

remote 命令:

更新近程分支: git remote update --prune