删除所有Git提交历史记录 [英] Delete all Git Commit History

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

问题描述

我正在尝试从Github获取回购协议,恢复过去的标签,将其推送到另一个具有删除所有历史记录的遥控器.除了删除所有提交日志之外,我可以执行以下所有操作.我想念的是什么?

I am trying to fetch a repo from Github, revert a tag in past, push it to another remote with deleting all history. I can do everything with below except deleting all commit logs. What I am missing?

git clone https://github.com/user/user-repo.git
cd user-repo
git reset --hard tags/v2.0
git remote add stash ssh://git@myserver:7999/myproject/user-repo.git
git push --force stash master

推荐答案

我认为您想要的是一个像新仓库一样的仓库,因此删除 .git/目录并重新初始化它将更简单.

I thought what you want is a repo like a new one, so deleting the .git/ directory and re-initing it will be more simple.

git clone https://github.com/user/user-repo.git
cd user-repo
git reset --hard tags/v2.0

rm -rf .git/
git init
git add .
git commit -m 'first commit'

git remote add stash ssh://git@myserver:7999/myproject/user-repo.git
git push --force stash master

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

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