How to reset a git repository to the initial state without deleting data
2025/03/16
# save backup if necessary # get initial commit sha-id $ git rev-list --max-parents=0 HEAD # <initial-commit-sha-id> # change the state to the initial commit $ git reset --soft <initial-commit-sha-id> # amend the initial commit $ git commit --amend -m "Initial commit" # sync the remote $ git push -f