git工具

This commit is contained in:
zhang hongbo 2026-01-27 16:15:52 +08:00
parent dc4acce758
commit 7158a33ff3
4 changed files with 0 additions and 462 deletions

View File

@ -1,83 +0,0 @@
================================================================================
操作类型: 提交并推送
开始时间: 2026-01-20 17:23:48
项目路径: E:/WorkSpace/MeowmentArt
================================================================================
[2026-01-20 17:23:48] [INFO] 日志: E:\WorkSpace\MeowmentArt\GitToolLog\提交并推送_20260120_172348.log
[2026-01-20 17:23:48] [INFO] 提交信息: 美术仓库初始化
[2026-01-20 17:23:48] [INFO] ============================================================
[2026-01-20 17:23:48] [INFO] 开始提交Art_SubModule
[2026-01-20 17:23:48] [INFO] ============================================================
[2026-01-20 17:23:48] [INFO]
步骤1: 检查改动
[2026-01-20 17:23:48] [INFO] 执行: git status --short
[2026-01-20 17:23:48] [INFO] D README.md
D README.md.meta
D "\346\265\213\350\257\2251.txt"
D "\346\265\213\350\257\2251.txt.meta"
?? HeadResource.prefab
?? HeadResource.prefab.meta
?? Scripts.meta
?? Scripts/
?? UISprites.meta
[2026-01-20 17:23:48] [INFO] 改动:
D README.md
D README.md.meta
D "\346\265\213\350\257\2251.txt"
D "\346\265\213\350\257\2251.txt.meta"
?? HeadResource.prefab
?? HeadResource.prefab.meta
?? Scripts.meta
?? Scripts/
?? UISprites.meta
[2026-01-20 17:23:48] [INFO]
步骤2: 添加改动
[2026-01-20 17:23:48] [INFO] 执行: git add .
[2026-01-20 17:23:48] [WARNING] warning: in the working copy of 'HeadResource.prefab', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'HeadResource.prefab.meta', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'Scripts.meta', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'Scripts/HeadResource.cs.meta', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'UISprites.meta', LF will be replaced by CRLF the next time Git touches it
[2026-01-20 17:23:48] [INFO]
步骤3: 提交
[2026-01-20 17:23:48] [INFO] 执行: git commit -m "美术仓库初始化"
[2026-01-20 17:23:48] [INFO] [detached HEAD dcd133c] 美术仓库初始化
8 files changed, 75 insertions(+), 4 deletions(-)
create mode 100644 HeadResource.prefab
rename README.md.meta => HeadResource.prefab.meta (62%)
delete mode 100644 README.md
rename "\346\265\213\350\257\2251.txt.meta" => Scripts.meta (57%)
create mode 100644 Scripts/HeadResource.cs
create mode 100644 Scripts/HeadResource.cs.meta
create mode 100644 UISprites.meta
delete mode 100644 "\346\265\213\350\257\2251.txt"
[2026-01-20 17:23:48] [INFO]
步骤4: Push前Pull
[2026-01-20 17:23:48] [INFO] 执行: git pull
[2026-01-20 17:23:49] [WARNING] You are not currently on a branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.
git pull <remote> <branch>
[2026-01-20 17:23:49] [ERROR] Pull失败-存在冲突!
[2026-01-20 17:23:49] [ERROR] 解决方法:
1.打开Art_SubModule目录
2.解决冲突
3.git add .
4.git commit
5.重新提交
================================================================================
结束时间: 2026-01-20 17:24:05
执行结果: 失败
================================================================================
!!! 操作失败 !!!
日志文件: E:\WorkSpace\MeowmentArt\GitToolLog\提交并推送_20260120_172348.log

View File

@ -1,27 +0,0 @@
================================================================================
操作类型: 更新
开始时间: 2026-01-20 17:12:17
项目路径: E:/WorkSpace/MeowmentArt
================================================================================
[2026-01-20 17:12:17] [INFO] 日志: E:\WorkSpace\MeowmentArt\GitToolLog\更新_20260120_171217.log
[2026-01-20 17:12:17] [INFO] ============================================================
[2026-01-20 17:12:17] [INFO] 开始更新子模块
[2026-01-20 17:12:17] [INFO] ============================================================
[2026-01-20 17:12:17] [INFO] 执行: git submodule update --init --recursive --remote --merge
[2026-01-20 17:12:19] [INFO] Updating 54a32bf..10480ba
Fast-forward
README.md.meta | 7 +++++++
"\346\265\213\350\257\2251.txt.meta" | 7 +++++++
2 files changed, 14 insertions(+)
create mode 100644 README.md.meta
create mode 100644 "\346\265\213\350\257\2251.txt.meta"
Submodule path 'Assets/Art_SubModule': merged in '10480ba573cacd75c1496737614d2d0d26147533'
[2026-01-20 17:12:19] [INFO]
更新完成!
================================================================================
结束时间: 2026-01-20 17:12:20
执行结果: 成功
================================================================================

View File

@ -1,352 +0,0 @@
# 美术Git操作指南
> 💡 **提示**命令行操作最准确可靠。SourceTree因版本不同界面可能有差异如遇找不到功能的情况请使用命令行。
---
## 📋 目录
1. [首次拉取项目](#首次拉取项目)
2. [日常提交流程](#日常提交流程)
3. [避免冲突](#避免冲突)
4. [解决冲突](#解决冲突)
5. [自动同步SubModule](#自动同步submodule)
---
## 首次拉取项目
### 命令行方式 ✅
```powershell
# 1. 克隆项目自动包含SubModule
git clone --recursive git@gitea.bywaystudios.com:zhanghongbo/MeowmentArt.git
# 2. 进入项目
cd MeowmentArt
# 3. 配置自动同步SubModule
git config submodule.recurse true
# 4. 配置用户信息
git config user.name "LiBoyang"
git config user.email "zhangsan@company.com"
# 完成可以用Unity打开项目了
```
### SourceTree方式
```
1. File → Clone / New
2. 填写信息:
Source URL: git@gitea.bywaystudios.com:你的用户名/MeowmentArt.git
Destination Path: E:\WorkSpace\MeowmentArt
✓ Recurse submodules ← 勾选这个!
3. 点击 Clone
4. 克隆完成后Tools → Options → Git
找到 Submodules 部分
✓ 勾选 Update submodules when pulling
```
---
## 日常提交流程
### 命令行方式 ✅
```powershell
# === 第一步在SubModule内提交必须先做 ===
cd Assets/Art_SubModule
# 查看修改了哪些文件
git status
# 添加文件(可以选择性添加)
git add Characters/hero.png # 添加单个文件
git add Characters/ # 添加整个文件夹
git add . # 添加所有修改
# 提交前先拉取更新(避免冲突)
git pull
# 提交
git commit -m "添加英雄角色贴图"
# 推送到远程
git push
# === 第二步回到主项目提交记录SubModule更新 ===
cd ../..
# 查看状态会看到SubModule有变化
git status
# 添加SubModule的变化
git add Assets/Art_SubModule
# 提交主项目
git commit -m "更新美术资源"
# 推送
git push
```
### SourceTree方式
```
=== 第一步提交SubModule ===
1. 在左侧 SUBMODULES 区域双击 "Assets/Art_SubModule"
会打开新窗口显示SubModule
2. 在SubModule窗口
- 点击 File Status
- 勾选要提交的文件
- 点击 Stage Selected暂存所选
- 底部输入提交信息:"添加英雄角色贴图"
- 点击 Commit
- 点击 Push
=== 第二步:提交主项目 ===
3. 回到主项目窗口:
- File Status 会显示 "Assets/Art_SubModule" 有变化
- 勾选这个变化
- 点击 Stage Selected
- 输入提交信息:"更新美术资源"
- 点击 Commit
- 点击 Push
```
**⚠️ 重要提示:**
- 必须先push SubModule再push主项目
- 两个都要提交,缺一不可
---
## 避免冲突
### 规则1提交前先拉取 ⭐ 最重要
```powershell
# 养成习惯:每次提交前先执行
cd Assets/Art_SubModule
git pull # 先拉取别人的更新
# 如果有冲突,现在解决比稍后解决简单
# 然后再提交你的修改
git add .
git commit -m "..."
git push
```
### 规则2明确分工
```
建议分工方式:
美术A → Characters/ 文件夹
美术B → UI/ 文件夹
美术C → Effects/ 文件夹
各自只修改自己负责的文件夹,不会冲突!
```
### 规则3提交前沟通
```
在团队群里:
"我正在修改 characters/hero.png大家别动这个文件"
"收到!"
→ 避免多人同时修改同一文件
```
### 规则4经常提交
```
✅ 好习惯:完成一个小功能就提交
❌ 坏习惯:攒几天的修改一次性提交
经常提交 = 减少冲突范围 = 更容易解决
```
---
## 解决冲突
### 场景1push时提示冲突
#### 命令行方式 ✅
```powershell
cd Assets/Art_SubModule
# 推送失败
git push
# ❌ error: failed to push some refs
# 原因:远程有新提交
# 解决方法:
# 1. 先拉取远程更新
git pull
# 2. 如果自动合并成功
# Merge made by... ← 看到这个说明成功
git push # 再次推送即可
# 3. 如果提示冲突
# CONFLICT (content): Merge conflict in xxx.png
# Auto-merging xxx failed
# 4. 查看哪些文件冲突
git status
# both modified: Characters/hero.png ← 冲突的文件
# 5A. 如果是二进制文件(图片、模型等)
# 选择保留谁的版本:
# 保留自己的版本
git checkout --ours Characters/hero.png
git add Characters/hero.png
# 或者保留别人的版本
git checkout --theirs Characters/hero.png
git add Characters/hero.png
# 5B. 如果是文本文件(配置文件等)
# 打开文件手动编辑,删除冲突标记:
# <<<<<<< HEAD
# 你的内容
# =======
# 别人的内容
# >>>>>>> xxx
# 保留需要的内容,删除标记
# 6. 标记冲突已解决
git add .
# 7. 完成合并
git commit -m "解决冲突"
# 8. 推送
git push
```
#### SourceTree方式
```
1. Push失败后会提示需要Pull
2. 点击 Pull 按钮
3. 如果有冲突,会显示:
⚠️ Conflicted files:
- Characters/hero.png
4. 右键冲突文件:
对于图片/模型等二进制文件:
- Resolve Conflicts → Use Mine (保留你的)
- Resolve Conflicts → Use Theirs (保留别人的)
对于文本文件:
- Resolve Conflicts → Launch External Merge Tool
- 或直接编辑文件
5. 解决后:
- 右键文件 → Mark Resolved
- 点击 Commit
- 输入 "解决冲突"
- Push
```
### 场景2主项目SubModule引用冲突
#### 命令行方式 ✅
```powershell
cd MeowmentArt # 主项目根目录
git pull
# CONFLICT (submodule): Merge conflict in Assets/Art_SubModule
# 解决方法:
# 1. 进入SubModule拉取最新
cd Assets/Art_SubModule
git pull
cd ../..
# 2. 标记已解决
git add Assets/Art_SubModule
# 3. 完成合并
git commit -m "同步SubModule更新"
# 4. 推送
git push
```
---
## 自动同步SubModule
### 问题pull时SubModule没更新
**原因**:默认情况下 `git pull` 不会自动更新SubModule
**解决方法**
#### 命令行方式 ✅
```powershell
cd MeowmentArt # 主项目根目录
# 一次性配置,永久生效
git config submodule.recurse true
# 配置后git pull 会自动同步SubModule
git pull # 会自动更新SubModule了
# 验证配置
git config --get submodule.recurse
# 输出: true = 配置成功
```
#### SourceTree方式
```
方式1全局设置
1. Tools → Options → Git
2. 找到 Submodules 部分
3. ✓ 勾选 Update submodules when pulling
方式2Pull时手动勾选
1. 每次点击 Pull 时
2. 在弹出对话框中
3. ✓ 勾选 Update submodules
4. 点击 OK
```
### 手动更新SubModule到最新版本
有时需要把SubModule更新到远程最新版本
```powershell
# 更新SubModule到远程最新
git submodule update --remote
# 或在SourceTree中
# Repository → Update Submodules...
```
---
**遇到问题随时联系客户端程序!**