简体   繁体   English

在保留历史记录的同时将git repo的根目录下移到文件夹层次结构的下一级

[英]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-branchgit 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.

相关问题 如何在保留历史记录的同时将 git repo 重新植根到父文件夹? - How do I Re-root a git repo to a parent folder while preserving history? 将文件夹从一个存储库复制/移动到另一个存储库,同时保留 Git 中的历史记录 - Copy/Move a folder from one repo to another repo while preserving history in Git 将子文件夹从一个 git repo 移动到另一个保留历史记录 - Moving subfolder from one git repo to another preserving history 在文件夹层次结构中将具有完整历史记录的所有git内容上移一级 - Moving all git content with complete history one-level up in the folder hierarchy 将git存储库向下移动到层次结构级别 - Moving a git repository down a hierarchy level git将文件夹下移一级并维护历史记录 - git move folder one level down and maintain history 如何在保留提交历史记录的同时将两个单独的 git 存储库作为两个目录添加到一个存储库中? - How to add two separate git repos into one repo as two directories while preserving commit history? 从一个仓库迁移到另一个仓库时保存提交历史 - Preserving commit history when moving from one repo to another 在移动GIT存储库时保留GIT提交的历史记录 - Preserving history of GIT commits while moving a GIT repository 将git存储库移动到一个层次结构级别 - Moving a git repository up one hierarchy level
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM