Git:我想重构我的代码库,并创建新的文件结构并移动。我的git历史会保留吗? [英] Git: I want to refactor my codebase, and create new files structures and move things around. Will my git history be maintained?

查看:149
本文介绍了Git:我想重构我的代码库,并创建新的文件结构并移动。我的git历史会保留吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打算批发重构我的整个项目。

这可能意味着一些文件重命名,但大多数情况下它将涉及很多重新组织文件。



创建新目录,文件从一个目录移动到另一个目录,或从一个目录移动到一个新目录等。



<如果你想在GIT中重构并移动文件,但是,如果你想在GIT中重构并移动文件,但是,仍然记录他们的历史,你需要使用 git mv



由于git管理内容的方式(它保存在不同的地方,文件名的内容和元数据)必须使用 git mv



完成 git mv 并将文件移动到新位置后,git会将文件标记为已重命名,这意味着它仍然保留其历史记录,但是文件被重命名 - 不是内容简单的文件名/路径

I'm planning to wholesale refactor my entire project.

It may mean some file renaming, but mostly it will involve a lot of re-organizing of files.

New directories being created, files moving from one directory to another, or from one to a new directory etc.

Will git and my repo maintain it's history under these changes?

解决方案

If you want to refactor in GIT and move files but still keep track of their history you need to use git mv.

Due to the way that git manages the content (It save in different places the content and the metadata of the file names) you must do it using git mv

Once you do git mv and move files to their new location git will mark the files as renamed which means that its still keeping its history but the file was renamed - not the content simply the file name/path

这篇关于Git:我想重构我的代码库,并创建新的文件结构并移动。我的git历史会保留吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆