Git 全局设置
git config --global user.name "ynwshy"
git config --global user.email "ynwshy@126.com"
本地项目连上 空的 git 仓库:
cd server
git init
touch README.md
git remote add origin https://gitee.com/ynwshy/server.git
git add .
git commit -m "Initial commit"
git push -u origin master
已有项目?
cd existing_git_repo
git remote add origin https://gitee.com/ynwshy/server.git
git push -u origin master
git push -u origin --all
git push -u origin --tags
常用命令
git clone
# 克隆远程项目
git clone
分支 branch
快速学会使用分支基本使用方法
1.创建分支 user 用户功能
git branch user
2.可随时运行查看当前分支情况
git branch
3.使用分支
git checkout user
回到master分支
git checkout master
在master分支上 把user分支合并过来到master上
再push到远程仓库
git merge user
git push
删除分支
git branch -d user
tag 标签
git标签分为两种类型:轻量标签和附注标签。轻量标签是指向提交对象的引用,附注标签则是仓库中的一个独立对象。建议使用附注标签。
# 创建轻量标签
$ git tag v0.1.2-light
创建轻量标签不需要传递参数,直接指定标签名称即可。
# 创建附注标签
$ git tag -a v0.1.2 -m “0.1.2版本”
创建附注标签时,参数a即annotated的缩写,指定标签类型,后附标签名。参数m指定标签说明,说明信息会保存在标签对象中。
# 删除标签
git tag -d v0.1.2
提交tag
git push不会将标签对象提交到git服务器,我们需要进行显式的操作:
$ git push origin v0.1.2 # 将v0.1.2标签提交到git服务器
$ git push origin –tags # 将本地所有标签一次性提交到git服务器
网友评论