基本问题:如何将git回购与它的克隆源分离?

Git分支-a显示:

* master
  remotes/origin/HEAD -> origin/master

我想删除所有关于起源的知识,以及相关的修订。

更长的问题:我想使用一个现有的subversion回购,并从中制作一些较小的git回购。每个新的git回购都应该有相关分支的完整历史。我可以修剪回购到只是想要的子树使用:

git filter-branch --subdirectory-filter path/to/subtree HEAD

但是生成的repo仍然包含起源/主分支下现在丢弃的子树的所有修订。

我意识到我可以使用-T标志来git-svn首先克隆subversion repo的相关子树。我不确定这是否会比后来在git repo副本上运行git filter-branch -subdirectory-filter的多个实例化更有效,但是,无论如何,我仍然希望打破与起源的链接。


当前回答

使用> git显示> git远程rm的origin

其他回答

使用> git显示> git远程rm的origin

在我的情况下,git分支-r将继续显示本地存储库上的origin/master(在我在远程和本地重命名master后)

这就解决了问题:

E:\SourceCode\PascalCoinGit\PascalCoin>git remote prune origin
Pruning origin
URL: https://github.com/SkybuckFlying/PascalCoin
 * [pruned] origin/master

E:\SourceCode\PascalCoinGit\PascalCoin>

命令:

git remote show origin

(以前见过,但完全忘了)

结果:

E:\SourceCode\PascalCoinGit\PascalCoin>git remote show origin
* remote origin
  Fetch URL: https://github.com/SkybuckFlying/PascalCoin
  Push  URL: https://github.com/SkybuckFlying/PascalCoin
  HEAD branch: PascalCoinMaster
  Remote branches:
    GUIExperimentalBugFixes1       tracked
    GUIExperimentalBugFixes2       tracked
    GUIExperimentalBugFixes3       tracked
    GUIExperimentalBugFixes4       tracked
    GUIExperimentalBugFixes5       tracked
    MergeTest                      tracked
    PIP-0026Windows7Implementation tracked
    PascalCoinMaster               tracked
    SkybuckMaster                  tracked
    TestPascalCoinMaster           tracked
    refs/remotes/origin/master     stale (use 'git remote prune' to remove)
  Local branches configured for 'git pull':
    GUIExperimentalBugFixes1       merges with remote GUIExperimentalBugFixes1
    GUIExperimentalBugFixes2       merges with remote GUIExperimentalBugFixes2
    GUIExperimentalBugFixes4       merges with remote GUIExperimentalBugFixes4
    GUIExperimentalBugFixes5       merges with remote GUIExperimentalBugFixes5
    MergeTest                      merges with remote MergeTest
    PIP-0026Windows7Implementation merges with remote PIP-0026Windows7Implementation
    SkybuckMaster                  merges with remote SkybuckMaster
  Local refs configured for 'git push':
    GUIExperimentalBugFixes1       pushes to GUIExperimentalBugFixes1       (up to date)
    GUIExperimentalBugFixes2       pushes to GUIExperimentalBugFixes2       (up to date)
    GUIExperimentalBugFixes3       pushes to GUIExperimentalBugFixes3       (up to date)
    GUIExperimentalBugFixes4       pushes to GUIExperimentalBugFixes4       (up to date)
    GUIExperimentalBugFixes5       pushes to GUIExperimentalBugFixes5       (up to date)
    MergeTest                      pushes to MergeTest                      (up to date)
    PIP-0026Windows7Implementation pushes to PIP-0026Windows7Implementation (fast-forwardable)
    PascalCoinMaster               pushes to PascalCoinMaster               (up to date)
    SkybuckMaster                  pushes to SkybuckMaster                  (up to date)
    TestPascalCoinMaster           pushes to TestPascalCoinMaster           (up to date)

E:\SourceCode\PascalCoinGit\PascalCoin>

是的,git分支-r现在显示它已经消失了!

删除现有的原点并向项目目录添加新的原点

>$ git remote show origin

>$ git remote rm origin

>$ git add .

>$ git commit -m "First commit"

>$ git remote add origin Copied_origin_url

>$ git remote show origin

>$ git push origin master

很简单:

git remote rm origin

至于filter-branch的问题——只要在你的filter branch命令中添加——prune-empty,它就会删除任何在你的结果repo中不包含任何变化的修订:

git filter-branch --prune-empty --subdirectory-filter path/to/subtree HEAD