我曾经和我的团队一起从事一个项目,在移至git之前,我们使用svn进行版本控制,现在svn的历史已久。我有我们开始使用的原始资源,我希望它显示在git历史记录中,这样我就可以看到我们对git或IDE所做的更改。
为了做到这一点,我必须能够将原始资源放在现有提交的下方,而不保留任何内容。
历史记录现在的样子:
我希望它看起来像:
我们还删除或重命名了许多文件,但我不希望它们属于存储库的当前状态。我所能做的最好的事情是在新分支上签出自述提交,将旧资源放在其顶部,然后使用其策略将母版合并到分支中以覆盖文件。我可以将旧资源视为第二次提交,然后将合并提交视为最后一次更改。它保留了已删除或重命名的文件,并且不显示现有文件的历史记录。
这甚至有可能不必重建整个仓库吗?
我并没有得到您想要的...。但是,如果我理解正确,您想在新资源之前添加旧资源...,然后在旧资源和新资源之间移动了很多文件,对吧?
确定,执行此操作:
git checkout -b temp revision1
// put the _old_ sources here
git add .
git commit -m "Old sources"
git checkout revision2 # where you have the new sources
git reset --soft temp # set the branch pointer in "old sources keep all files the way they are, everything that changed will be in index... even moved files
git commit -m "new sources¨
# let's move temp branch's pointer
git branch -f temp
git checkout temp
# now we replicate the other changes from master (master, right?)
git cherry-pick revision2..master
# if you like the result
git branch -f master # set master over here
git checkout master
git branch -d temp
您已经完成