From fbf20f6da46af4d8f86e1d263350d5aba0db327d Mon Sep 17 00:00:00 2001 From: Admin Date: Tue, 3 Mar 2026 14:17:04 +0800 Subject: [PATCH] =?UTF-8?q?security:=20=E7=A7=BB=E9=99=A4=E5=8C=85?= =?UTF-8?q?=E5=90=AB=E8=AE=A4=E8=AF=81=E4=BF=A1=E6=81=AF=E7=9A=84Git?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=96=B9=E6=B3=95.md=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 从Git仓库中删除了包含敏感认证信息的Git提交方法.md文件, 并将其添加到.gitignore中以防止意外提交。 --- .gitignore | 1 + Git提交方法.md | 161 ------------------------------------------------- 2 files changed, 1 insertion(+), 161 deletions(-) delete mode 100644 Git提交方法.md diff --git a/.gitignore b/.gitignore index 89cc49c..387f993 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ .vscode/c_cpp_properties.json .vscode/launch.json .vscode/ipch +Git提交方法.md diff --git a/Git提交方法.md b/Git提交方法.md deleted file mode 100644 index 7fdd506..0000000 --- a/Git提交方法.md +++ /dev/null @@ -1,161 +0,0 @@ -# Git 提交和推送成功方法 - -## 项目配置信息 -注意本文件涉及认证,不上传git!!!! -- **远程仓库地址**: `http://lmhrt.cn:6771/ming/Rader_IQ.git` -- **主分支**: `main` -- **Git 路径**: `C:\Program Files\Git\bin\git.exe` -- **Git 认证URL格式**: `"C:\Program Files\Git\bin\git.exe" remote set-url origin http://ming:mq20221109@lmhrt.cn:6771/ming/Rader_IQ.git` -## 方法一:使用 git.bat 脚本(推荐) - -### 脚本位置 -`git.bat` 位于项目根目录 - -### 使用步骤 -1. 双击运行 `git.bat` -2. 查看步骤 1:检查 Git 状态 -3. 查看步骤 2:添加所有文件到暂存区 -4. 查看步骤 3:输入提交信息(默认:Update project) -5. 查看步骤 4:自动拉取远程代码 -6. 查看步骤 5:推送到远程仓库 - -### 脚本流程 -``` -[1/5] 检查 Git 状态 -[2/5] 添加所有文件到暂存区 -[3/5] 提交更改 -[4/5] 拉取远程代码 -[5/5] 推送到远程仓库 -``` - -## 方法二:手动执行 PowerShell 命令 - -### 完整流程 -```powershell -# 1. 查看当前状态 -& "C:\Program Files\Git\bin\git.exe" status - -# 2. 添加所有修改的文件 -& "C:\Program Files\Git\bin\git.exe" add -A - -# 3. 提交更改 -& "C:\Program Files\Git\bin\git.exe" commit -m "你的提交信息" - -# 4. 拉取远程代码(避免冲突) -& "C:\Program Files\Git\bin\git.exe" pull - -# 5. 推送到远程仓库 -& "C:\Program Files\Git\bin\git.exe" push -``` - -## 常见问题及解决方案 - -### 1. 推送失败,提示需要拉取 -**问题**: 提示远程有新提交 -```powershell -# 解决方案:先拉取远程代码 -& "C:\Program Files\Git\bin\git.exe" pull - -# 解决冲突后再推送 -& "C:\Program Files\Git\bin\git.exe" push -``` - -### 2. 认证失败 -**问题**: `Authentication failed for 'http://lmhrt.cn:6771/ming/Rader_IQ.git/'` - -**解决方案**: -```powershell -# 方案1:在 URL 中包含认证信息 -& "C:\Program Files\Git\bin\git.exe" remote set-url origin http://ming:mq20221109@lmhrt.cn:6771/ming/Rader_IQ.git -& "C:\Program Files\Git\bin\git.exe" push - -# 方案2:配置凭据存储 -& "C:\Program Files\Git\bin\git.exe" config --global credential.helper store -& "C:\Program Files\Git\bin\git.exe" push -``` - -### 3. 忘记添加 .gitignore -**问题**: 不应该被跟踪的文件被提交了 - -```powershell -# 从暂存区移除已添加的文件 -& "C:\Program Files\Git\bin\git.exe" rm -r --cached .pio - -# 提交更改 -& "C:\Program Files\Git\bin\git.exe" commit -m "Remove .pio from tracking" -& "C:\Program Files\Git\bin\git.exe" push -``` - -### 4. 修改最后一次提交信息 -**问题**: 提交信息写错了,但还没有推送 - -```powershell -# 修改最后一次提交(未推送) -& "C:\Program Files\Git\bin\git.exe" commit --amend -m "新的提交信息" -``` - -### 5. 查看文件历史 -```powershell -# 查看指定文件的历史 -& "C:\Program Files\Git\bin\git.exe" log --follow 文件名 - -# 查看指定文件在某次提交的内容 -& "C:\Program Files\Git\bin\git.exe" show 提交哈希:文件名 -``` - -## 提交信息规范 - -### 格式建议 -``` -<类型>: <简短描述> - -<详细描述(可选)> - -<相关 issue(可选)> -``` - -### 类型说明 -- `feat`: 新功能 -- `fix`: 修复 bug -- `docs`: 文档更新 -- `style`: 代码格式调整 -- `refactor`: 重构代码 -- `test`: 测试相关 -- `chore`: 构建/工具链相关 - -### 示例 -``` -feat: 添加心率平滑处理算法 - -实现了基于移动平均的心率数据平滑处理, -提高了心率监测的稳定性。 -``` - -## 成功案例 - -### 本次成功提交 -- **提交哈希**: `aa57e81` -- **提交信息**: `Update project` -- **修改文件**: 4 个文件 -- **新增行数**: 134 行 -- **删除行数**: 88 行 -- **推送状态**: ✅ 成功 - -### 修改的文件 -- `src/main.cpp` - 修改 -- `src/radar_vitals.cpp` - 修改 -- `src/radar_vitals.h` - 修改 -- `git.bat` - 新增 - -## 最佳实践 - -1. **提交前检查**: 使用 `git status` 确认要提交的文件 -2. **频繁提交**: 小步快跑,每个功能点完成后立即提交 -3. **清晰的提交信息**: 使用规范的提交信息格式 -4. **推送前拉取**: 使用 `git pull` 避免冲突 -5. **定期同步**: 与团队成员保持代码同步 - -## 参考资料 - -- [Git 官方文档](https://git-scm.com/doc) -- [Rader_Success_5 项目](http://lmhrt.cn:6771/ming/Rader_Success_5.git)