Search:   Dictionary All Posts
Store Your Knowledge at the Brain Bank!

Git Delete Previous Commits

By Jamie in Lessons / Programming - General  3.26.19  
Summary - Instructions on how to delete the git history from a project and then upload without the history.
Be sure you have the latest version of the project you want.

Then, delete the git folder.

Then, run 'git init' to install a fresh version of git. 

Then, reset the git origin master with 'git remote add origin repoURL'

Then git add .

Then git commit -m "initial commit"

Then git push -u origin master


If you want to save some of the latest previous commits, instead do this...

Delete the project folder and clone the project again, but like this..

1. git clone --depth 5 -b master repoURL

The number is how many commits from the latest you want to clone.

Be sure to run npm install to get back all of the dependencies.

Then, delete the repo from git and create a new repo. 

Then, add, commit and push to the new repo.