git ls date is git sub命令显示第一个和最后一个提交日期。
git-ls-date的Python项目详细描述
git ls日期
git ls date is git sub命令显示第一个和最后一个提交日期。
示例
基本
默认选项是
- 日期=短
- 格式=“{fd}{fh}{ld}{lh}{f}”
$ git ls-date 2013-11-05 7ab1b16 2013-11-05 7ab1b16 README.rst 2013-11-07 342ad26 2013-11-10 2826492 git_ls_date.py
多久以前?
git ls-date --date relative --format "first commit is {fd: <20} | {f}" first commit is 6 days ago | .gitignore first commit is 3 days ago | .python-version first commit is 3 days ago | LICENSE first commit is 77 minutes ago | MANIFEST.in first commit is 6 days ago | README.rst first commit is 3 days ago | git_ls_date.py first commit is 3 days ago | setup.py first commit is 3 days ago | test_git_ls_date.py first commit is 30 hours ago | testfiles/testdirectory/testfile4 first commit is 30 hours ago | testfiles/testfile1 first commit is 30 hours ago | testfiles/testfile2 first commit is 30 hours ago | testfiles/testfile3 first commit is 3 days ago | tox.ini
仅显示提交哈希
$ git ls-date --format="{lh} {f} 7ab1b16 README.rst 2826492 git_ls_date.py
按上次提交日期对文件排序
$ git ls-date --date iso --format "{ld} {f}" | sort 2013-11-05 04:40:11 +0900 .gitignore 2013-11-05 04:40:11 +0900 README.rst 2013-11-07 23:22:29 +0900 setup.py 2013-11-07 23:34:59 +0900 LICENSE 2013-11-08 15:36:16 +0900 .python-version 2013-11-09 15:07:06 +0900 testfiles/testdirectory/testfile4 2013-11-09 19:11:38 +0900 testfiles/testfile2 2013-11-09 19:11:38 +0900 testfiles/testfile3 2013-11-09 21:03:55 +0900 testfiles/testfile1 2013-11-09 22:22:38 +0900 tox.ini 2013-11-10 15:32:19 +0900 test_git_ls_date.py 2013-11-10 18:28:24 +0900 git_ls_date.py 2013-11-10 19:45:40 +0900 MANIFEST.in
要求
- python 2.6/2.7/3.2/3.3或更高版本
我在用2.6.8,2.7.5,3.2.5,3.3.2测试。
安装
从pypi安装
easy_install git-ls-date
或
pip install git-ls-date
从github安装
git clone https://github.com/ton1517/git-ls-date.git cd git-ls-date python setup.py install
手动设置
- 将git_ls_date.py复制到您路径中的目录。
- 将其重命名为git ls date。
- 将其更改为可执行文件。
cd ~/bin wget https://raw.github.com/ton1517/git-ls-date/master/git_ls_date.py -O git-ls-date chmod +x git-ls-date
用法
- 用法:
git ls-date [--date=<option>] [--format=<format>] [<path>]... git ls-date -h | --help git ls-date -v | --version
- 选项:
-h --help Show help. -v --version Show version. -d --date=(relative|local|default|iso|rfc|short|raw) Date option.(default: short) -f --format=<format> Show-format option. See SHOW FORMAT.(default: "{fd} {fh} {ld} {lh} {f}")
- 显示格式:
格式选项允许您指定要显示的信息。
- 占位符:
- {ld}:最后提交日期
- {fd}:第一个提交日期
- {lh}:上次提交哈希
- {fh}:第一个提交哈希
- {f}:文件名
- 例如:
$ git ls-date --date=local --format="{fd} {fh} {ld} {lh} {f}" ./README.rst Tue Nov 5 04:40:11 2013 7ab1b16 Tue Nov 5 04:40:11 2013 7ab1b16 README.rst
您可以看到更多格式规范到http://docs.python.org/3/library/string.html?highlight=string.format#formatspec
gitconfig
您可以在.gitconfig中写入选项
- 例如:
[git-ls-date] date = relative format = {lh} {ld: <25} {f}
$ git ls-date 7ab1b16 6 days ago README.rst 2826492 2 hours ago git_ls_date.py