git 命令

This commit is contained in:
徐永兴 2023-02-10 09:35:46 +08:00
parent 74872212af
commit f72198d0df
3 changed files with 133 additions and 0 deletions

View File

@ -7,6 +7,9 @@
- Docker
- [install.md](./docker/install.md) Docker 安装
- git
- [cli.md](./git/cli.md) git 命令
- [ssh-key.md](./git/ssh-key.md) 生成 ssh key
- nginx
- conf.d
- default.conf 默认配置文件

108
git/cli.md Normal file
View File

@ -0,0 +1,108 @@
<h1>
Git
<h3>常用命令</h3>
</h1>
### 设置用户信息
```bash
git config --global user.name 'userName'
git config --global user.email service@yinghuasoft.com
```
### 克隆项目
```bash
git clone https://github.com/mick-xu/rapid-app.git
```
### 克隆名称为 "dev" 分支
```sh
git clone -b dev https://github.com/mick-xu/rapid-app.git
```
### 添加文件至暂存区
```bash
# 添加本地所有 untrack 的文件至暂存区
git add .
# 根据 .gitignore 过滤后添加 untrack 的文件至暂存区
git add *
```
### 提交至本地仓库
```bash
git commit -m [message]
git commit [file1] [file2] ... -m [message]
# 不需要执行 git add直接提交
git commit -a
# 跳过验证直接提交
git commit -m [message] --no-verify
git commit -m [message] -n
```
### 推送至远程仓库
```bash
git push
```
### 分支操作
```bash
# 查看远程分支
git branch -a
# 本地新建 "dev" 分支
git checkout -b dev
# 将本地 "dev" 分支推送至远程仓库
git push --set-upstream origin dev
# 切换至名称为 "dev" 的远程分支
$ git checkout -b dev origin/dev
```
### 初始化本地仓库,并推送至远程仓库
```bash
# 初始化
git init
# 添加 readme 文件
git add README.md
# 提交
git commit -m "first commit"
git remote add origin git@github.com:mick-xu/xxx.git
git push -u origin master
```
### 清除 git 缓存
```bash
git rm -r --cached .
```
### git commit type
```bash
feat: 增加新特性、新功能,
fix: 修补 bug,
perf: 性能,
style: 样式、格式,
docs: 文档变更,
test: 测试,
refactor: 重构,
build: 打包,
ci: ,
chore: 其他、日常事务,
revert: ,
wip: 正在开发中,
workflow: ,
types: ,
release: 发布
```

22
git/ssh-key.md Normal file
View File

@ -0,0 +1,22 @@
<h1>
Git
<h3>生成 SSH 密钥</h3>
</h1>
### 先执行以下语句来判断是否已经存在本地公钥:
```sh
cat ~/.ssh/id_rsa.pub
```
### 你可以按如下命令来生成 ssh key
```bash
ssh-keygen -t rsa -C "service@yinghuainfo.com"
```
### 用以下命令获取你生成的公钥
```bash
cat ~/.ssh/id_rsa.pub
```