项目作者: filipnet

项目描述 :
Delete the complete history of a git repository
高级语言:
项目地址: git://github.com/filipnet/git-delete-history.git
创建时间: 2020-05-22T08:25:55Z
项目社区:https://github.com/filipnet/git-delete-history

开源协议:BSD 3-Clause "New" or "Revised" License

下载


git-delete-history

Delete the complete history of a git repository

Purpose of use

  • Even before you decide to turn a previously private repository into a public one, it may be necessary to remove the commit history first
  • The code could have previously contained sensitive data, which was later moved to other files and excluded from the upload with .gitignore

WARNING

This will remove your history completely, You will not be able to recover it again.

GIT commands

The following commands can be copy and paste into the command line with line comments, e.g. from VSCode
Update: GitHub changed the default branch from MASTER to MAIN, so you have to take care in here:

MASTER

  1. # Create a new orphan branch (will not be shown by command 'git branch')
  2. git checkout --orphan temp_branch
  3. # Add all files to this new orphan branch
  4. git add -A
  5. git commit -am "update"
  6. # Delete master branch
  7. git branch -D master
  8. # Rename the previously created orphan branch to 'master branch'
  9. git branch -m master
  10. # Push new master branch without history data to remote git repository
  11. git push -f origin master

MAIN

  1. # Create a new orphan branch (will not be shown by command 'git branch')
  2. git checkout --orphan temp_branch
  3. # Add all files to this new orphan branch
  4. git add -A
  5. git commit -am "update"
  6. # Delete main branch
  7. git branch -D main
  8. # Rename the previously created orphan branch to 'main branch'
  9. git branch -m main
  10. # Push new master branch without history data to remote git repository
  11. git push -f origin main

LICENSE

git-delete-history and all individual scripts are under the BSD 3-Clause license unless explicitly noted otherwise. Please refer to the LICENSE