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

手动设置

  1. 将git_ls_date.py复制到您路径中的目录。
  2. 将其重命名为git ls date。
  3. 将其更改为可执行文件。
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

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java ArrayOutOfBoundsException与org。日食swt。图样图像数据。布利特   java为什么Hazelcast CacheLoader类需要对所有客户端可见?   如何在java中迭代xml   java概要文件不是工件名称的一部分   java将多个Spring MVC应用程序映射到根Servlet   java SetContentView参数显示错误   java Cucumber类扩展步骤定义和挂钩   java如何动态添加JFace向导页面   amazon web services使用AWS Java SDK通过AWS API网关从S3下载文本文件   Android上的java软键盘   如何在Java中像在C#中一样创建泛型扩展方法?   使用JPA的java多列类型