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