Git: I want to refactor my codebase, and create new files structures and move things around. Will my git history be maintained?

僤鯓⒐⒋嵵緔 提交于 2019-12-25 03:11:49

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/31257932/git-i-want-to-refactor-my-codebase-and-create-new-files-structures-and-move-th

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!