Skip to content

Update main.yml

Update main.yml #1

Workflow file for this run

name: Clean Commit History
on: [push]
jobs:
clean_history:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v2
- name: Remove commit history
run: |
# Set up Git user
git config --global user.name "Wenjie Fu"
git config --global user.email "[email protected]"
# 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 "Keep only the latest version"
# Delete the old branch
git branch -D test
# Rename the current branch to main
git branch -m test
# Force push to update the repository
git push -f origin main