Git 命令行学习六(标签,别名,开源中国)

使用Tag标签

知识点
	•	系统版本号管理
	•	git tag [tag_name] [commit_id]
	•	git show [tag_name]
	•	git tag -d [tag_name]

系统版本号管理
任何软件系统,应用程序在发布时都应该给一个版本号,来管理每次发布的内容,便于今后的管理。
例如:
1.1.4
NNN.abc.xxx
	•	NNN:大版本号
	•	abc:每次做出的小更新时,发布的版本号
	•	xxx:每次bug修正时发布的版本号

实战演习
$ git tag	//查看当前标签
$ git tag v1.0.0	//给当前版本打标签
$ git tag	
$ nano index.htm
...
#修正bug1
...
$ git add .
$ git commit -m "fixed bug1."
$ git tag v1.0.1
$ git tag
$ nano index.htm
...
#修正bug2
...
$ git add .
$ git commit -m "fixed bug2."
$ git tag v1.0.2
$ git tag
$ nano index.htm
...
#新功能追加
...
$ git add .
$ git commit -m "added feature1."
$ git tag v1.1.0
$ git tag
$ git show v1.0.1
$ git show v1.0.2


使用别名
在Git中可以将经常使用的命令以别名缩写的方式简化使用。

知识点
	•	git config --global alias.[name] [command_name]  :name 自己命名(co),command_name 原始命令(checkout)

实战演习
#将checkout命令简化为co
$ git config --global alias.co checkout
#将branch命令简化为br
$ git config --global alias.br branch
#将commit命令简化为cm
$ git config --global alias.cm commit
#将status命令简化为st
$ git config --global alias.st status
$ git br
$ git co dev
$ git st
$ git config -l
当然这种别名的定义根据每个人的使用习惯不同而不同,也可以在项目开始前作为项目的统一规则制定下来,使每个项目开发成员都统一使用一套大家都认可的别名,这样提高项目组内部的沟通效率。

玩转开源中国Gitee
本期课程为您讲解如何使用Git命令连接远程服务器,如果编写提交代码到服务器端,完成团队的协同开发。

知识点
	•	git clone [url]
	•	git remote -v
	•	git push [origin] [master]


操作步骤
	1.	git clone 把远程库克隆到本地文件夹
	2.	编辑本地文件夹的文件
	3.	提交编辑的文件到本地信息库(git add ./git commit)
	4.	将本地库同步(sync)到远程Git服务器

实战演习
通过操作开源中国LearnOSC库,为您展示如何使用分支,如果提交代码,让您了解整个Git远程库的使用过程。
$ git clone https://gitee.com/zhaialan/test
$ cd LearnOSC
$ git status
$ git branch
$ git branch -a
$ git branch dev remotes/origin/dev
$ git branch
$ git checkout dev
$ git status
$ nano README.md
...
git config --global color.ui true
...
$ git add .
$ git commit -m "为初期设定增加color.ui选项"
$ git status
$ git remote -v
$ git push origin dev
原创文章 88 获赞 21 访问量 2万+

猜你喜欢

转载自blog.csdn.net/ZhaiAlan/article/details/93722466