git的标签与别名的学习

1.查看分支

[root@localhost gitroot]# git branch
* master

2.(1)打标签

[root@localhost gitroot]# git tag v1.0

(2)查看详细信息

[root@localhost gitroot]# git show v1.0
commit 7c3cdc402f1cd4eb6d6befc10fc8553be0a659
Merge: c113874 1e4e60d
Author: lsk <example@qq.com>
Date:   Tue Dec 29 14:02:01 2020 -0500

    2.txt

diff --cc 2.txt
index 151f472,56b7c61..5f1d0ec
--- a/2.txt
+++ b/2.txt
@@@ -1,2 -1,3 +1,2 @@@
--lushuaizi
- add 2
+ 2

(3)查看所有标签

[root@localhost gitroot]# git tag
v1.0

(4)查看历史提交的commit

[root@localhost gitroot]# git log --pretty=oneline --abbrev-commit
7c3cdc4 2.txt
c113874 2.txt
1e4e60d 2.txt
8d35751 new file 2.txt
17b6365 new file 1.txt

(5)给历史提交的commit打标签

[root@localhost gitroot]# git tag v0.9 7c3cdc4

(6)查看标签(可以看到多了一个v0.9)

[root@localhost gitroot]# git tag
v0.9
v1.0

(7)对标签进行描述

[root@localhost gitroot]# git tag  -a v0.8 -m "lulushuaizi" 8d35751

查看标签(多了一个 v0.8)

[root@localhost gitroot]# git tag
v0.8
v0.9
v1.0

(8)删除标签

[root@localhost gitroot]# git tag -d v0.8
Deleted tag 'v0.8' (was 4ee8766)

(9)推送远程标签

[root@localhost gitroot]# git push origin v1.0

在这里插入图片描述
在这里插入图片描述
(10)推送所有标签

[root@localhost gitroot]# git tag
v0.8
v0.9
v1.0
[root@localhost gitroot]# git push --tag origin

在这里插入图片描述
(11)删除本地标签

[root@localhost gitroot]# git tag v1.0 -d
Deleted tag 'v1.0' (was 7c3cdc4)

(12)删除远程标签

[root@localhost gitroot]# git push origin :refs/tags/v1.0

在这里插入图片描述
2.git别名
使用别名可以提高工作效率
(1)查询系统自带别名

[root@localhost gitroot]# git config --list|grep alias

(2)设置别名
[root@localhost gitroot]# git config --global alias.ci commit #输入ci=commit
查看别名

[root@localhost gitroot]# git config --list|grep alias
alias.ci=commit

(3)别名的使用

[root@localhost gitroot]# touch ls
[root@localhost gitroot]# git add ls
[root@localhost gitroot]# git ci -m"ls"
[master 6c303fb] ls
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 ls

取消别名

[root@localhost gitroot]# git config --global --unset alias.ci

取消后查看
在这里插入图片描述

3.查询log的小技巧

[root@localhost gitroot]# git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
[root@localhost gitroot]# git config --list|grep alias
alias.ci=commit
alias.lg=log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
[root@localhost gitroot]# git lg
* 6c303fb - (HEAD, master) ls (3 minutes ago)
*   7c3cdc4 - (tag: v0.9) 2.txt (6 hours ago)
|\  
| * 1e4e60d - 2.txt (6 hours ago) <lsk>
* | c113874 - 2.txt (6 hours ago) <lsk>
|/  
* 8d35751 - new file 2.txt (6 hours ago) <lsk
* 17b6365 - (tag: v0.8) new file 1.txt (6 hou
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值