Elton's Blog

Git学习笔记(3) — 标记(tag)

by on 七.22, 2009, under Linux

当执行git log

1
2
3
4
5
$ git log
<strong>commit 29293409f6d4a389fee75bd42fba5194fee5b899</strong>
Author: elton <elton.zheng.sh@gmail.com>
Date:   Wed Jul 22 12:26:11 2009 +0800
...

其中commit后面的数字是一个唯一的版本号,每次提交都不同。

显示版本信息

1
$git show 29293409f6d4a389fee75bd42fba5194fee5b899

就显示这个版本的详细信息
也可以使用

1
$git show 292934

只要你这个版本号足够区分其他版本就可以了。

1
$git show master

显示master分支的版本信息

1
$git show HEAD

HEAD代表当前分支的头(也就是最近一次commit)
每一次commit都会有”parent commit”,可以使用^表示parent:

1
2
3
4
5
6
7
$git show HEAD^ //查看HEAD的父母的信息
$git show HEAD^^ //查看HEAD的父母的父母的信息
$git show HEAD~4 //查看HEAD上溯4代的信息
 
要注意的是git-merge是会产生双父母的,这种情况这样处理:
$git show HEAD^1 //查看HEAD的第一个父母
$git show HEAD^2 //查看HEAD的第二个父母

当你觉得某个版本是一个有意义的里程碑的时候,你可以为这个版本打一个标记

1
$git tag V3 5b888

这样就给5b888这个版本打了一个tag,之后就可以使用这个版本来作其他的操作了
如显示详情

1
$git show V3

创建一个基于V3的分支

1
$ git branch stable V3




:

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit my friends!

A few highly recommended friends...