2020年7月30日 星期四

[Git 文章收集] Deleting your git commit history without removing repo on Github/Bitbucket

Source From Here
Question
When you have just found out that you or a fellow team mate has committed sensitive data into your Github repo. What do you do? If you do not have hundreds of commits already. You can follow the steps mentioned below. Source: StackOverflow

WARNING: This should be used with care! It also removes the configuration of the repo.

How-To

Step 1
Remove all history
$ cd myrepo
$ rm -rf .git

Step 2
Init a new repo
$ git init
$ git add .
$ git commit -m "Removed history, due to sensitive data"

Step 3
Push to remote
$ git remote add origin github.com:yourhandle/yourrepo.git
$ git push -u --force origin master

Supplement
2.5 Git Basics - Working with Remotes

沒有留言:

張貼留言

[Git 常見問題] error: The following untracked working tree files would be overwritten by merge

  Source From  Here 方案1: // x -----删除忽略文件已经对 git 来说不识别的文件 // d -----删除未被添加到 git 的路径中的文件 // f -----强制运行 #   git clean -d -fx 方案2: 今天在服务器上  gi...