Skip to content

Instantly share code, notes, and snippets.

@HereOrCode
Created March 17, 2025 09:05
Show Gist options
  • Save HereOrCode/42a4034ede062a8e5b0b261e73f25643 to your computer and use it in GitHub Desktop.
Save HereOrCode/42a4034ede062a8e5b0b261e73f25643 to your computer and use it in GitHub Desktop.
Create New Repository

When submitting a project to GitHub, you might accidentally include sensitive information like passwords or email addresses. Here's how to remove those records, create a brand-new repository, and keep the code unchanged:

  1. Create a new blank branch
    git checkout --orphan latest_branch

  2. Add all files
    git add -A

  3. Commit the changes
    git commit -am "."

  4. Force delete the old branch (e.g., if it’s main)
    git branch -D main

  5. Rename the current branch to main
    git branch -m main

  6. Force push to the remote repository
    git push -f origin main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment