Skip to content

Instantly share code, notes, and snippets.

@jagroop
Last active December 13, 2017 17:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jagroop/651def27af81dea971af0cbf484f3527 to your computer and use it in GitHub Desktop.
Save jagroop/651def27af81dea971af0cbf484f3527 to your computer and use it in GitHub Desktop.
Delete git history
#!/bin/bash

git checkout --orphan latest_branch # Checkout
git add -A # Add all the files
git commit -am "first commit" # Commit the changes
git branch -D master # Delete the branch
git branch -m master # Rename the current branch to master
git push -f origin master # Finally, force update your repository

Short Hand :

git checkout --orphan latest_branch && git add -A && git commit -am "first commit" && git branch -D master && git branch -m master && git push -f origin master
published: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment