2020年11月9日 星期一

[Git 常見問題] How to delete all commit history in github?

 Source From Here

Question
I want to delete all commit history but keep the code in its current state because, in my commit history, there are too many unused commits.

How can I do it?

HowTo
Deleting the .git folder may cause problems in your git repository. If you want to delete all your commit history but keep the code in its current state, it is very safe to do it as in the following:

1. Checkout
# git checkout --orphan latest_branch

2. Add all the files
# git add -A

3. Commit the changes
# git commit -am "commit message"

4. Delete the branch
# git branch -D master

5. Rename the current branch to master
# git branch -m master

6. Finally, force update your repository
# git push -f origin master


沒有留言:

張貼留言

[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...