-
Notifications
You must be signed in to change notification settings - Fork 20
34 lines (27 loc) · 835 Bytes
/
main.yml
File metadata and controls
34 lines (27 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
name: Clean Commit History
on: workflow_dispatch
jobs:
clean_history:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Remove commit history
run: |
# Set up Git user
git config --global user.name "Wenjie Fu"
git config --global user.email "wjfu99@outlook.com"
git branch
ls
# Create a new orphan branch with the latest commit
git checkout --orphan latest_commit
# Add all files to the new branch
git add -A
# Commit the changes
git commit -m "Final Commit"
# Rename the current branch to main
git branch -m latest_commit
# Force push to update the repository
git push -f origin latest_commit:main