[英]Moving root of git repo down one level in folder hierarchy while preserving history
So I have a git repo in this structure: 所以我有一个git repo这个结构:
app
app_one
app_two
app_three
The git repo root is in app. git repo根在应用程序中。 What I want is the root to simply be a folder containing app_one, app_two, app_three.
我要的是将根简单地设为包含app_one,app_two,app_three的文件夹。
app_one
app_two
app_three
But the caveat is I want to do this while maintaining the current history of the file. 但是需要注意的是,我想在保持文件当前历史记录的同时执行此操作。 Aka when I push this change to github, I don't want everything to show it was updated 3 seconds ago.
也就是当我将此更改推送到github时,我不希望所有内容都显示它是3秒钟前更新的。
I want to do this while maintaining the current history of the file.
我想在保持文件当前历史记录的同时执行此操作。
The easiest (and best IMO) way: 最简单(也是最好的IMO):
git mv app_one app_two app_three .
git commit
You will still have access to the entire history of changes for all files in every folder. 您仍然可以访问每个文件夹中所有文件的全部更改历史记录。
I don't want everything to show it was updated 3 seconds ago.
我不希望所有内容都显示它是3秒钟前更新的。
This would require entirely rewriting the commit history with git filter-branch
or git rebase
. 这将需要使用
git filter-branch
或git rebase
完全重写提交历史记录。 These are both dangerous if there are other developers who are working on existing branches. 如果还有其他开发人员在现有分支机构上工作,这两者都是危险的。 Also, they take a lot more time and effort.
此外,他们需要花费更多的时间和精力。 The above solution will work just fine for more cases.
上述解决方案在更多情况下都可以正常工作。
For information about viewing history information across file moves see this question . 有关查看跨文件移动的历史记录信息的信息,请参阅此问题 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.