简体   繁体   English

如何在git存储库中“取消存储”或将文件从一个存储库移动到另一个存储库

[英]How do I either “unrm” in git repository or move files from one repository to another

I have a large rails project currently using rails 2.3.11 and I want to migrate it up to rails 3. I had an idea that I'd like to try but I need some git help. 我有一个目前使用Rails 2.3.11的大型Rails项目,我想将其迁移到Rails3。我有一个想尝试的想法,但是我需要一些git帮助。

What I want to do is start from a fresh new rails 3 app. 我想做的是从一个全新的Rails 3应用程序开始。 One idea is to get in my current rails project directory and delete everything. 一种想法是进入我当前的Rails项目目录并删除所有内容。 Then do a commit so the tree is empty. 然后执行一次提交,使树为空。 Then create a new rails 3 project. 然后创建一个新的Rails 3项目。 This way I am starting fresh so everything will be current. 这样,我就可以重新开始,以便一切都将是最新的。

Then as I add the old controllers, etc back into the project, I want to "unrm" them. 然后,当我将旧的控制器等添加回项目中时,我想“整理”它们。 Git knows the history of the files and I'd like to keep that history. Git知道文件的历史记录,我想保留该历史记录。

Another alternative would be to start a fresh rails 3 app and then somehow transport files from the old git repository to the new git repository but I'd like to keep the history of the file. 另一个选择是启动一个新的Rails 3应用程序,然后以某种方式将文件从旧的git存储库传输到新的git存储库,但我想保留文件的历史记录。

This is a half baked idea but it seems a more viable approach to moving this particular project is to essentially start over fresh and then move things from the old project into the new project. 这是一个半生半熟的主意,但似乎将这个特定项目迁移的更可行的方法是从头开始,然后从旧项目迁移到新项目。 But when I move things from old to new, I'd like to keep the history of each particular file. 但是,当我从旧版本转移到新版本时,我想保留每个特定文件的历史记录。

Can anyone suggest a method of doing what I've just outlined? 谁能建议我做概述的方法?

First: check out this to automatically find some of the things that need to be upgraded: https://github.com/rails/rails_upgrade 首先:检查此内容以自动查找一些需要升级的内容: https : //github.com/rails/rails_upgrade

To answer your question: You can upgrade your rails gem and then run rails new . 要回答您的问题:您可以升级rails gem,然后运行rails new . to generate a new rails 3 app on top of your rails 2 app. 在rails 2应用之上生成一个新的rails 3应用。 It will clobber a few of your important files, but you can use git diff to figure out what was in them and copy the important things into the new file. 它会破坏您的一些重要文件,但是您可以使用git diff找出其中的内容,然后将重要内容复制到新文件中。 Finally, there's a few things you might need to manually delete (like all of the files in the script/ folder except for rails). 最后,您可能需要手动删除一些内容(例如脚本/文件夹中的所有文件(除rails外))。 "Generating" a new rails 3 app on top of your existing app seems to be the recommended practice, and worked well for me when I upgraded a rather large and old app. 建议在您现有的应用程序之上“生成”一个新的Rails 3应用程序,当我升级一个相当旧的应用程序时,对我来说效果很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM