This commit is contained in:
27
File/Shell/Clean_git.sh
Normal file
27
File/Shell/Clean_git.sh
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/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
|
Reference in New Issue
Block a user