Files
2026-06-11 23:38:54 +08:00

114 lines
2.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 一、你的两个仓库(永久地址)
## 1. 后端Java
```
https://git.njtobobsales.top/guxz/my-springboot-project.git
```
## 2. 前端aue
```
https://git.njtobobsales.top/guxz/aue.git
```
---
# 二、最重要铁律(必须记住)
1. **.git 隐藏文件夹 = Git 灵魂 → 不许删、不许发、不许改**
2. **项目文件夹可改名、可移动、可覆盖 → 完全没问题**
3. **哪个文件夹打开 Git Bash就操作哪个仓库**
---
# 三、通用操作(前后端 100% 一样)
## 第一步
进入项目文件夹 → 右键 → **Git Bash Here**
---
# 四、日常更新代码(自己修改代码时)
```bash
# 检查远程是否有更新(不会修改本地代码)
git fetch origin
git status
git pull # 多人每次开始写代码前必用
git add . # 记录新增/修改
git add -A # 记录所有新增/修改/删除
git commit -m "说明" # 提交本地
git push # 上传到仓库
git push origin main -f # 强制上传到远程
git config --global credential.helper manager # 记住密码
```
---
# 五、前端专用:接收 ZIP 包覆盖更新(重点)
前端发 ZIP → 解压 → **直接覆盖你本地前端文件夹内所有文件**
执行这 4 行(**可同步删除旧文件**
```bash
git pull
git add -A # 同步:新增 + 修改 + 删除(关键)
git commit -m "前端新版更新"
git push
```
---
# 六、查看当前仓库(确认不搞错)
```bash
git remote -v
```
- 看到 `my-springboot-project` = 后端
- 看到 `aue` = 前端
---
# 七、回退版本(后悔药)
```bash
git reset --hard HEAD^ # 回退到上一版
git push -f # 强制同步远程
```
---
# 八、放弃本地所有修改(还原到最新版)
```bash
git reset --hard HEAD
git clean -fd
```
---
# 九、切换前后端仓库方法
**关闭当前 Git Bash → 进入另一个项目文件夹 → 重新打开 Git Bash**
自动识别仓库,**不用改网址**。
---
# 十、你以后终身标准工作流
1. 改后端 → 进后端文件夹开 Bash
2. 改前端 → 进前端文件夹开 Bash
3. 开始写代码 → `git pull`
4. 写完代码 → `git add .` / 前端覆盖用 `git add -A`
5. 提交 → `git commit -m "说明"`
6. 上传 → `git push`
---
# 🎯 最简万能命令(前后端通用)
## 自己改代码
```bash
git pull
git add .
git commit -m "更新"
git push
```
## 前端发 ZIP 覆盖
```bash
git pull
git add -A
git commit -m "前端更新"
git push
```
---