This commit is contained in:
42
Git/Git清除提交记录.md
Normal file
42
Git/Git清除提交记录.md
Normal file
@@ -0,0 +1,42 @@
|
||||
> 作者:丁辉
|
||||
|
||||
# 清除GitHub中的所有提交历史记录
|
||||
|
||||
1. 创建了一个新的分支
|
||||
|
||||
```bash
|
||||
git checkout --orphan latest_branch
|
||||
```
|
||||
|
||||
2. 添加所有文件
|
||||
|
||||
```bash
|
||||
git add -A
|
||||
```
|
||||
|
||||
3. 提交更改
|
||||
|
||||
```bash
|
||||
git commit -am "commit message"
|
||||
```
|
||||
|
||||
4. 删除分支
|
||||
|
||||
```bash
|
||||
git branch -D main
|
||||
```
|
||||
|
||||
5. 将当前分支重命名
|
||||
|
||||
```bash
|
||||
git branch -m main
|
||||
```
|
||||
|
||||
6. 最后,强制更新存储库
|
||||
|
||||
```bash
|
||||
git push -f origin main
|
||||
```
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user