🖖 Greetings, this site is prototype for low code CMS deployments: Discover MoreStar on GitHub

SKNOW.IT

Cover Image for How to completely clear git repository, without deleting it

How to completely clear git repository, without deleting it

Local git repository only

To erase your whole history and start over again, run the commands below and start committing again:

cd <repo>
rm -rf .git
git init

If you want to remove both files and history, run the commands below and start committing again:

cd <repo>
rm -rf *
git init

Local repo with a remote repository

To start over again, but retain history there is a quick way:

git pull
git rm -r *
git commit
git push

To also clean up the history (N.B. this will cause trouble for anyone else linked to that same remote repository):

git checkout <first commit hash>
git rm -r *
touch README
git add README
git commit --amend
git push -f

Create an empty README file for the first commit, as a commit cannot be empty.

Refs:

GET IN TOUCH

Site Mod
Site Mod
Wrote this on
Categrised as:
DevelopmentSnippets

Tagged#HowTogitversion-control


More Articles

How to Create a Block Pattern for WordPress

Creating Block Patterns for WordPress: A Beginner’s Guide Want to streamline your website design process? Block Patterns offer pre-designed arrangements of blocks that you can easily insert into your pages and posts. Let’s learn how to create your own. 1. Understand Block Patterns: 2. Set Up Your Development Environment: 3. Create a Block Pattern Directory: […]

Read More… from How to Create a Block Pattern for WordPress

Shaun Knowles
Shaun Knowles
Cover Image for How to Check and Update Your Git Version

How to Check and Update Your Git Version

Change is inevitable and, in the technical world, usually beneficial. Keeping your Git installation up to date is highly recommended, it gives you all the latest features, improvements, bug fixes, and more. Let’s see how to check which Git version you’re currently using and how to update it to the latest version. To stay up […]

Read More… from How to Check and Update Your Git Version

Shaun Knowles
Shaun Knowles