git 操作

分支

1
2
3
4
5
6
7
8
9
10
11
12
# 删除本地分支
git branch -d bug
# 删除远程分支
git push origin --delete bug
# 重命名分支
git branch -m old new
# 撤销 commit
git reset HEAD~
# clone 指定分支
git clone -b branchname https://**
# 添加远程地址
git remote add origin https://***.git

stash 开发

紧急模式,用来临时修复bug

1
2
3
4
5
6
# 保存到临时的地方
git stash
# 查看临时暂存的地方
git stash list
# 回归正常的开发
git stash pop

创建标签

1
2
3
4
5
6
7
8
9
10
11
12
# 创建 tag
git tag -a v1.6 -m 'msg: my version 1.4'
# 查看 tag
git tag
# 提交
git push origin v1.6
# 提交所有 tag
git push origin --tags
# 删除本地 tag
git tag -d v1.6
# 删除线上 tag
git push origin --delete v1.6

指定密钥

文件位置

1
~/.ssh/config

1
2
3
4
# 不同的地址指定不同的私钥
Host <domain>
User <user>
IdentityFile <rsa path>
  • example
1
2
3
Host github.com
User example
IdentityFile ~/.ssh/example
1
2
# linux
chmod 600 ~/.ssh/example

other

1
git clone https://github.com/odoo/odoo.git --depth 1 --branch 11.0 --single-branch odoo11

解析:--depth 深度;--branch 分支;--single-branch 单一分支