作为在github中的不同回购的repo的fork子目录

chr*_*ian 13 git github bower

我想在其他类似的任务中为League of Moveable Type的Chunk字体创建一个凉亭包/样式表.

我想知道是否可以将他们的"webfonts"目录分成新的repo中的"fonts"目录.这将允许我创建一个bower.json文件和样式表.

谢谢,

mu *_*u 無 15

我不认为你可以直接在github上的web UI上分叉,但如果你可以克隆它并手动推送东西,你可以做以下事情

  • 要将`new_branch`推送到新github仓库的`master`分支,请使用`git push upstream new_branch:master` (4认同)
  • 知道如何使原始存储库识别以这种方式创建的“分叉”为合法分叉并允许提交 PR 吗? (3认同)

use*_*236 7

Github 在https://help.github.com/en/articles/splitting-a-subfolder-out-into-a-new-repository发布了一篇文章如何做到这一点:

您可以将 Git 存储库中的文件夹转换为全新的存储库。

如果您创建存储库的新克隆,当您将文件夹拆分为单独的存储库时,您不会丢失任何 Git 历史记录或更改。

  1. 打开终端。

  2. 将当前工作目录更改为要创建新存储库的位置。

  3. 克隆包含子文件夹的存储库。

    $ git clone https://github.com/USERNAME/REPOSITORY-NAME
    
    Run Code Online (Sandbox Code Playgroud)
  4. 将当前工作目录更改为您克隆的存储库。
    $ cd REPOSITORY-NAME
    
    Run Code Online (Sandbox Code Playgroud)
  5. 要从存储库中的其余文件中过滤掉子文件夹,请运行 git filter-branch,提供以下信息:

    • FOLDER-NAME:项目中要从中创建单独存储库的文件夹。

    • BRANCH-NAME:当前项目的默认分支,例如 master 或 gh-pages。

    $ git filter-branch --prune-empty --subdirectory-filter FOLDER-NAME  BRANCH-NAME 
     # Filter the specified branch in your directory and remove empty commits
     > Rewrite 48dc599c80e20527ed902928085e7861e6b3cbe6 (89/89)
     > Ref 'refs/heads/BRANCH-NAME' was rewritten 
    
    Run Code Online (Sandbox Code Playgroud)

    存储库现在应该只包含子文件夹中的文件。

  6. 在 GitHub 上创建一个新存储库。

  7. 在新 GitHub 存储库的快速设置页面顶部,单击剪贴板以复制远程存储库 URL。

    • 复制远程仓库 URL 字段
  8. 检查存储库的现有远程名称。例如,origin 或 upstream 是两个常见的选择。

    $ git remote -v
     > origin  https://github.com/USERNAME/REPOSITORY-NAME.git (fetch) 
     > origin  https://github.com/USERNAME/REPOSITORY-NAME.git (push)
    
    Run Code Online (Sandbox Code Playgroud)
  9. 使用现有的远程名称和您在步骤 7 中复制的远程存储库 URL 为新存储库设置新的远程 URL。
    git remote set-url origin
    https://github.com/USERNAME/NEW-REPOSITORY-NAME.git
    
    Run Code Online (Sandbox Code Playgroud)
  10. 验证远程 URL 是否已更改为您的新存储库名称。
    $ git remote -v
     # Verify new remote URL
     > origin  https://github.com/USERNAME/NEW-REPOSITORY-NAME.git (fetch)
     > origin  https://github.com/USERNAME/NEW-REPOSITORY-NAME.git (push)
    
    Run Code Online (Sandbox Code Playgroud)
  11. 将您的更改推送到 GitHub 上的新存储库。
    git push -u origin BRANCH-NAME
    
    Run Code Online (Sandbox Code Playgroud)