之前用 SVN 的时候经常用 svn info 反应当前svn的基本信息,但是在Git 中没有类似的功能。
比如查看当前版本的一些基本信息:
[code lang="c"]
git remote -v
git branch -r
git branch
[/code]
每次敲很多的命令是很麻烦的,但是Hack里面力量是无限的,在 git-info.txt 有些简单的命令组合可以完成我们的需求。
运行的效果如下:
[code lang="c"]
== Remote URL: origin git://git.kernel.org/pub/scm/linux/kernel/git/rdunlap/linux-docs/.git
== Remote Branches:
origin/HEAD
origin/doc-subdirs
origin/master
== Local Branches:
* doc-subdirs
== Configuration (.git/config)
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = git://git.kernel.org/pub/scm/linux/kernel/git/rdunlap/linux-docs/.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "doc-subdirs"]
remote = origin
merge = refs/heads/doc-subdirs
== Most Recent Commit
commit 31c00fc15ebd35c1647775dbfc167a15d46657fd
Author: Randy Dunlap
Date: Thu Nov 13 21:33:24 2008 +0000
Create/use more directory structure in the Documentation/ tree.
Create Documentation/blockdev/ sub-directory and populate it.
Populate the Documentation/serial/ sub-directory.
Move MSI-HOWTO.txt to Documentation/PCI/.
Move ioctl-number.txt to Documentation/ioctl/.
Update all relevant 00-INDEX files.
Update all relevant Kconfig files and source files.
Signed-off-by: Randy Dunlap
Type ‘git log’ for more commits, or ‘git show’ for full commit details.
[/code]
Git-info 脚本如下:
[code lang="c"]
#!/bin/bash
# author: Duane Johnson
# email: duane.johnson@gmail.com
# date: 2008 Jun 12
# license: MIT
#
# Based on discussion at http://kerneltrap.org/mailarchive/git/2007/11/12/406496
pushd . >/dev/null
# Find base of git directory
while [ ! -d .git ] && [ ! `pwd` = "/" ]; do cd ..; done
# Show various information about this git directory
if [ -d .git ]; then
echo "== Remote URL: `git remote -v`"
echo "== Remote Branches: "
git branch -r
echo
echo "== Local Branches:"
git branch
echo
echo "== Configuration (.git/config)"
cat .git/config
echo
echo "== Most Recent Commit"
git log --max-count=1
echo
echo "Type 'git log' for more commits, or 'git show' for full commit details."
else
echo "Not a git repository."
fi
popd >/dev/null
[/code]
在这里有些有关git info讨论话题。
Links:
1. Git Info (kinda like ’svn info’) http://blog.inquirylabs.com/2008/06/12/git-info-kinda-like-svn-info/
2. git info 脚步 http://blog.inquirylabs.com/wp-content/uploads/2008/06/git-info.txt
3. KernelTrap 有关git info讨论的话题
Recent Comments