Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove origin from git repository

Tags:

git

git-svn

Basic question: How do I disassociate a git repo from the origin from which it was cloned?

git branch -a shows:

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

and I want to remove all knowledge of origin, and the associated revisions.

Longer question: I want to take an existing subversion repo and make a number of smaller git repos from it. Each of the new git repos should have the full history of just the relevant branch. I can prune the repo to just the wanted subtree using:

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

but the resulting repo still contains all the revisions of the now-discarded subtrees under the origin/master branch.

I realise that I could use the -T flag to git-svn to clone the relevant subtree of the subversion repo in the first place. I'm not sure if that would be more efficient than later running multiple instantiations of git filter-branch --subdirectory-filter on copies of the git repo but, in any case, I would still like to break the link with the origin.

like image 939
awy Avatar asked Feb 10 '12 08:02

awy


People also ask

How do I remove a remote from git?

The git remote remove command removes a remote from a local repository. You can use the shorter git remote rm command too. The syntax for this command is: git remote rm <remote-url>.


1 Answers

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 
like image 135
Amber Avatar answered Oct 23 '22 03:10

Amber