文章目录
- 一、查询提交记录哈希码
- 二、为某个提交设置标签 git tag v1.0 2321849
- 三、查询标签 git tag
- 四、查询标签信息 git show v1.0
- 五、创建标签并指定说明文字 git tag -a v0.9 -m "text" faafce2
- 六、删除标签 git tag -d v1.0
一、查询提交记录哈希码
1、git log --pretty=oneline --abbrev-commit
执行
git log --pretty=oneline --abbrev-commit
命令 , 查询提交记录 , 前面的 7 7 7 位就是哈希码 ;
D:\Git\git-learning-course>git log --pretty=oneline --abbrev-commit
2321849 (HEAD -> master) dev1
2bd4156 (origin/master, origin/HEAD) Merge branch 'feature1' into 'master'
d2fde16 Merge branch 'master' into 'feature1'
faafce2 master
3d9de4a feature1
e9d0ace master
c9842ef master
26b1978 feature1
5220e76 update
8e848b1 Merge branch 'revert-c31c3379' into 'master'
bea66a2 Revert "Merge branch 'feature1'"
c31c337 Merge branch 'feature1'
f5900c5 & simple
17d0c76 AND simple
4e31d93 modify dev file1
d74ada0 remove file3.txt
297422e modify file1 and 2
dd0db50 modify file2
63a9ef1 modify file1
72e82e0 modify file4
5bcec31 add 1 files
f95c831 add 3 files
f2f9a97 Update README.md
5d7e8d4 Initial commit
2、git reflog
执行
git reflog
命令 , 查询当前的操作日志 , 前面的 7 7 7 位就是哈希码 ;
D:\Git\git-learning-course>git reflog
2321849 (HEAD -> master) HEAD@{0}: cherry-pick: dev1
2bd4156 (origin/master, origin/HEAD) HEAD@{1}: checkout: moving from dev_1 to master
301c619 (dev_1) HEAD@{2}: commit (cherry-pick): dev1
29206c6 (dev) HEAD@{3}: checkout: moving from dev to dev_1
29206c6 (dev) HEAD@{4}: commit: dev4
31914ab HEAD@{5}: commit: dev3
cc5fe50 HEAD@{6}: commit: dev2
f12e2d3 HEAD@{7}: commit: dev1
2bd4156 (origin/master, origin/HEAD) HEAD@{8}: checkout: moving from master to dev
2bd4156 (origin/master, origin/HEAD) HEAD@{9}: clone: from https://codechina.csdn.net/han12020121/git-learning-course
二、为某个提交设置标签 git tag v1.0 2321849
执行
git tag v1.0 2321849
命令 , 为 哈希码为 2321849 的提交 , 设置标签 " v1.0 " , 其中 2321849 哈希码对应的提交为 :
2321849 (HEAD -> master) dev1
三、查询标签 git tag
执行
git tag
命令 , 查询当前设置过的标签 ;
执行过程如下 :
D:\Git\git-learning-course>git tag
v1.0
四、查询标签信息 git show v1.0
执行
git show v1.0
命令 , 查询 " v1.0 " 标签的详细信息 ;
执行过程 :
D:\Git\git-learning-course>git show v1.0
commit 2321849278544ea9f305c828232b3494cc39d845 (HEAD -> master, tag: v1.0)
Author: han1202012 <octopus_truth@163.com>
Date: Thu Dec 9 20:58:46 2021 +0800
dev1
diff --git a/file1.txt b/file1.txt
index ab5d90e..aa886c6 100644
--- a/file1.txt
+++ b/file1.txt
@@ -1,4 +1,6 @@
hello world
hello world
-git branch dev
\ No newline at end of file
+git branch dev
+
+dev
\ No newline at end of file
五、创建标签并指定说明文字 git tag -a v0.9 -m “text” faafce2
执行
git tag -a v0.9 -m "version 0.9 released" faafce2
命令 , 其中 -a v0.9
指定了标签的名称 , -m "version 0.9 released"
指定了标签的说明文字 ; faafce2 哈希码对应如下提交 ;
faafce2 master
执行过程 :
D:\Git\git-learning-course>git tag -a v0.9 -m "version 0.9 released" faafce2
D:\Git\git-learning-course>git show v0.9
tag v0.9
Tagger: han1202012 <octopus_truth@163.com>
Date: Thu Dec 9 23:09:15 2021 +0800
version 0.9 released
commit faafce22ca36a1194a68e3795fcb88e81111fa39 (tag: v0.9)
Author: hanshuliang <octopus_truth@163.com>
Date: Thu Dec 9 12:35:30 2021 +0800
master
diff --git a/README.txt b/README.txt
index e92a228..1f7391f 100644
--- a/README.txt
+++ b/README.txt
@@ -1 +1 @@
-master & feature1
+master
执行
git tag
命令 , 查询当前设置过的标签 ;
六、删除标签 git tag -d v1.0
执行
git tag -d v1.0
命令 , 删除 v1.0 标签 ; 再次执行
git tag
查询当前标签 , 发现 v1.0 标签已经被删除 ;
执行过程 :
D:\Git\git-learning-course>git tag -d v1.0
Deleted tag 'v1.0' (was 2321849)
D:\Git\git-learning-course>git tag
v0.9