Files
Linux/File/Shell/Clean_git.sh
offends cee91802b3
Some checks failed
continuous-integration/drone Build is failing
synchronization
2025-08-25 15:57:40 +08:00

27 lines
722 B
Bash

#!/bin/bash
#############################################################################################
# 用途: 清理 Git 提交记录
# 作者: 丁辉
# 编写时间: 2024-01-03
# 使用方法
# curl -sfL https://gitee.com/offends/Linux/raw/main/File/Shell/Clean_git.sh | bash
#############################################################################################
# 定义变量
# 你的分支名称
BRANCH="main"
# 创建了一个新的分支
git checkout --orphan latest_branch
# 添加所有文件
git add -A
# 提交更改
git commit -am "synchronization"
# 删除分支
git branch -D $BRANCH
# 将当前分支重命名
git branch -m $BRANCH
# 最后,强制更新存储库
git push -f origin $BRANCH