删除所有Git提交历史记录

now*_*way 18 git github git-stash

我正在尝试从Github获取一个repo,在过去恢复一个标记,将其推送到另一个远程并删除所有历史记录.除了删除所有提交日志之外,我可以使用以下内容执 我错过了什么?

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
Run Code Online (Sandbox Code Playgroud)

pkt*_*yue 47

我认为你想要的是一个像新的回购,所以删除.git/目录并重新启动它会更简单.

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
Run Code Online (Sandbox Code Playgroud)