复制没有历史记录的git存储库

时间:2018-06-04 01:16:06

标签: git repository

我想将我们的存储库复制到一个新的存储库中,使我们的分支保持当前状态,但删除所有无用的提交历史记录。

有没有聪明的方法呢?而不是一个接一个地克隆和复制每个分支?

2 个答案:

答案 0 :(得分:0)

这可能是您正在寻找的,但我不确定这是否是您想要的确切答案

Stephenhardy在这里建议 - https://gist.github.com/stephenhardy/5470814

他的帖子是

-- Remove the history from 
rm -rf .git

-- recreate the repos from the current content only
git init
git add .
git commit -m "Initial commit"

-- push to the github remote repos ensuring you overwrite history
git remote add origin git@github.com:<YOUR ACCOUNT>/<YOUR REPOS>.git
git push -u --force origin master

答案 1 :(得分:0)

如上所述Copy a git repository without history制作新的回购并复制每个分支是最简单的解决方案

相关问题