如何删除github中的所有提交历史记录? [英] how to delete all commit history in github?

查看:1974
本文介绍了如何删除github中的所有提交历史记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想删除所有提交历史记录,但将代码保持为当前状态。



因为在我的提交历史记录中,有太多未使用的提交。



我该怎么做?



有没有任何git命令可以做到这一点?

  git filter-branch? 
git rebase?
...

我在github.com上的代码主机。

解决方案

删除 .git 文件夹可能会导致您的git存储库出现问题。如果您想删除所有提交历史记录,但保持代码处于当前状态,则执行以下操作非常安全:


  1. 结帐



    git checkout --orphan latest_branch


  2. 添加所有文件
    $ b $ git add -A

    li>
  3. 提交更改



    git commit -am提交消息


  4. 删除分支



    git branch -D master < code $










    $ git branch -m master


  5. 最后,强制更新您的存储库

    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:

  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

PS: this will not keep your old commit history around

这篇关于如何删除github中的所有提交历史记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆