git代码不变,删除所有commit记录

1.2k 记录 发表评论

把旧项目提交到Git服务器上,会有很多以前的commit记录。

由于各种各样的原因,不希望在新的Git服务器上显示这些commit信息。

那如何删除这些commit记录,形成一个全新的仓库,并且保持代码不变呢?

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

参考资料:

  1. how to delete all commit history in github?

 

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

昵称 *