gpt4 book ai didi

git 将所有内容向上移动一级,适用于所有分支

转载 作者:行者123 更新时间:2023-12-03 20:29:21 25 4
gpt4 key购买 nike

我想将 git 存储库中的所有内容向上移动一级,并且需要将其应用于我拥有的每个分支。从字面上看,我有:

+--repo
+----+.git
+----+folder
+--------+ A
+--------+ B

我只想:
+--repo
+----+.git
+----+A
+----+B

本帖 How can I move all git content one-level up in the folder hierarchy?有一个很好的答案,建议这样做:
git mv folder/* ./ -k

现在我如何处理所有分支?我能想到:
  • git mv对于主人,然后 git rebase所有人,在大师
  • git mv所有分支机构?

  • 一个比另一个有优势吗?我也看到了一些基于 git filter-branch --index-filter 的答案(回答 here)但不明白如何将其应用于我的案例。

    谢谢!

    最佳答案

    我会使用 new git filter-repo , 其中 does replace the old git filter-branch or BFG .
    它带有 many usage examples ,包括基于路径的过滤,以便您将文件夹内容移动到顶部(假设顶部目录仅包含文件夹)

    cd /path/to/second/clone
    git filter-repo --path-rename folder/:
    默认情况下, git filter-repo适用于所有分支机构。

    关于git 将所有内容向上移动一级,适用于所有分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53076877/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com