搜索
写经验 领红包
 > 财经

如何清除git仓库的所有提交记录(git清除提交记录)

导语:如何清除git仓库的所有提交记录

如何清除git仓库的所有提交记录(git 清除提交记录)

原理:创建干净新分支,替换旧的分支,然后强推到远程仓库。

操作步骤

1.切换到新的分支

git checkout --orphan latest_branch

2.缓存所有文件(除了.gitignore中声明排除的)

 git add -A

3.提交跟踪过的文件(Commit the changes)

 git commit -am 

4.删除master分支(Delete the branch)

git branch -D master

5.重命名当前分支为master(Rename the current branch to master)

 git branch -m master

6.提交到远程master分支 (Finally, force update your repository)

 git push -f origin master

开发中严格要求提交日志的规范,避免输入一些敏感信息。

免责声明:本站部份内容由优秀作者和原创用户编辑投稿,本站仅提供存储服务,不拥有所有权,不承担法律责任。若涉嫌侵权/违法的,请反馈,一经查实立刻删除内容。本文内容由快快网络小洁创作整理编辑!