Resetting A Repository
Steps to reset a GitHub repository:
if (!repository)
, clone the repository:
git clone <remote repository>
cd <repository>
info
To check the current remote url of the repository:
git remote -v
- Remove all git history:
rm -rf .git
- Reinitialize git:
git init
- Reconnect the repository to GitHub:
git remote add origin <remote repository url>
- Create a new commit:
touch README.md # Add at least one file to commit
git commit -m "Reset repository"
- Force
push
to GitHub:
git push --force origin main
Replace main
with the branch name if it's different.
caution
- This completely erases all previous commits and files.
- GitHub will not retain old versions after the force push.