How to remove origin from git repository

Fairly straightforward:

git remote rm origin

As for the filter-branch question - just add --prune-empty to your filter branch command and it'll remove any revision that doesn't actually contain any changes in your resulting repo:

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

Remove existing origin and add new origin to your project directory

>$ 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

In my case git branch -r would keep showing origin/master on the local repository (after I renamed master on remote and local)

This fixed it:

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

E:\SourceCode\PascalCoinGit\PascalCoin>

Command:

git remote show origin

(Seen it before but completely forgot about it)

Result:

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>

Yup, git branch -r now shows it's gone!

Tags:

Git

Git Svn