synchronization
Some checks failed
continuous-integration/drone Build is failing

This commit is contained in:
2025-08-25 15:57:40 +08:00
commit cee91802b3
106 changed files with 9124 additions and 0 deletions

128
Git/GIt的使用.md Normal file
View File

@@ -0,0 +1,128 @@
> 本文作者:丁辉
# GIt的使用
[官网](https://git-scm.com/book/zh/v2/Git-%E5%88%86%E6%94%AF-%E5%88%86%E6%94%AF%E7%9A%84%E6%96%B0%E5%BB%BA%E4%B8%8E%E5%90%88%E5%B9%B6)
## 基础命令
- 新建分支
```bash
git branch demo
```
- 切换分支
```bash
git checkout demo
```
- 新建并切换到新分支
```bash
git checkout -b demo
```
- 合并分支
```bash
git merge hotfix
```
- 删除分支
```bash
git branch -d hotfix
```
- 查看状态
```bash
git status
```
- 启动一个合适的可视化合并工具
```bash
git mergetool
```
- 添加仓库
```bash
git remote add origins Git地址
```
- 拉取代码
```bash
git pull origins
```
- 查看提交信息
```bash
git log
```
- 回滚代码
```bash
git reset --hard ID信息
```
- 不回滚已修改的代码
```bash
git reset ID信息
```
- 清楚缓存
```bash
git credential-cache exit
```
## 跨分支合并某个提交记录
> 例子:假如我有 A 、B 分支
1. 切换到 A 分支
```bash
git checkout <A分支>
```
2. 查看提交日志拿到值
```bash
git log
```
3. 切换到 B 分支
```bash
git checkout <B分支>
```
4. 合并
```bash
git cherry-pick '获取到的提交记录值'
```
5. 检查提交记录,查看是否将 A 文件合并到了 B 仓库
```bash
git log
```
6. 提交文件
```bash
git add .
git push
```