如何删除github中的所有提交历史记录? [英] how to delete all commit history in github?
问题描述
我想删除所有提交历史记录,但将代码保持为当前状态。
因为在我的提交历史记录中,有太多未使用的提交。
我该怎么做?
有没有任何git命令可以做到这一点?
git filter-branch?
git rebase?
...
我在github.com上的代码主机。
删除 .git
文件夹可能会导致您的git存储库出现问题。如果您想删除所有提交历史记录,但保持代码处于当前状态,则执行以下操作非常安全:
-
结帐
git checkout --orphan latest_branch
-
添加所有文件
li>
$ b $ git add -A
-
提交更改
git commit -am提交消息
-
删除分支
git branch -D master < code $
$ git branch -m master -
最后,强制更新您的存储库
git push -f origin master
PS:this不会将您的旧提交历史记录保存在
中
I want to delete all commit history , but keep the code in current state .
because in my commit history , there are too many unused commit .
How can i do it ?
is there any git command can do this?
git filter-branch ?
git rebase ?
...
my code host in github.com.
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:
Checkout
git checkout --orphan latest_branch
Add all the files
git add -A
Commit the changes
git commit -am "commit message"
Delete the branch
git branch -D master
Rename the current branch to master
git branch -m master
Finally, force update your repository
git push -f origin master
PS: this will not keep your old commit history around
这篇关于如何删除github中的所有提交历史记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!