[英]Project migration to new directory - keeping Git history
I have recent migrated a Java EE project from 5 to 6, as this required quite a big overhaul I created a new EE6 skeleton project and copied most of the code across manually. 我最近将Java EE项目从5迁移到了6,因为这需要进行大修,我创建了一个新的EE6框架项目,并手动复制了大部分代码。 I now have my working EE6 project (and an obsolete EE 5 project). 我现在有我正在工作的EE6项目(还有一个过时的EE 5项目)。
I would like to keep my Git history, is there are recommended way to move the .git directory into the new project so that all the updates are picked up as a new commit? 我想保留我的Git历史记录,是否有推荐的方法将.git目录移动到新项目中,以便将所有更新都作为新提交提交? Or can I just copy the .git folder over? 还是可以将.git文件夹复制过来? Or do I have to start from scratch and lose the history? 还是我必须从头开始并失去历史?
Thanks, I am sure this must have been asked before but I have been unable to find any questions that relate 谢谢,我敢肯定这一定是已经问过的,但是我找不到任何相关的问题
You can copy the .git
folder in the new project, and check that a git status does pick up all your changes ( git add -A .
after that, in order to add any new, modified or deleted files). 您可以在新项目中复制.git
文件夹,并检查git状态是否确实吸收了所有更改( git add -A .
之后,为了添加任何新的,修改的或删除的文件)。
A more clean solution would be to : 一个更干净的解决方案是:
git init .
) 在项目中初始化一个空的git repo( git init .
) git remote add origin /path/to/previous/project
, where a .git/
folder reside. 作为远程添加到上一个项目的路径( git remote add origin /path/to/previous/project
, .git/
文件夹所在的位置。 Then, using git branch
and git reset
: 然后,使用git branch
和git reset
:
git fetch
git branch master origin/master
git reset --soft master
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.