Apaar Bhatnagar
Apaar Bhatnagar

Reputation: 119

Changing remote git repository

I have cloned a repo into my local folders and now I wanted to change my git repository to some other url. I have already changed it using

git remote set-url origin git://new.url.here

and when I am doing

git remote -v

it shows me the correct repository in which I want to work.But when I do

git branch --all

it shows me the old branches in the old repository. I am wondering why?? As my new repo doesn't have any branches yet.

Upvotes: 2

Views: 50

Answers (2)

Vale
Vale

Reputation: 1124

The branches loaded in your repository are the old one anyway, since otherwise they would be lost. If you do not need them (as you have done the upstream push to the new remote), follow these instructions to delete the old remote branches (watch out though: you should change back to the old remote, delete, and switch back again) How do I delete a Git branch both locally and remotely?

Upvotes: 1

Mureinik
Mureinik

Reputation: 312219

You are in fact seeing local copies of the old remote branches. You could use git remote prune origin to remove them. To be on the safe side, it's recommended you run git remote prune origin --dry-run first, just to see what exactly would be removed before removing it.

Upvotes: 1

Related Questions