views:

275

answers:

3

I created a local GIT repository on Windows. Let's call it AAA. I staged, committed, and pushed the contents to GitHub. [email protected]:username/AAA.git

I realized I made a mistake with the name.

On GitHub, I renamed it to [email protected]:username/BBB.git

Now, on my Windows machine, I need to change this [email protected]:username/AAA.git to this [email protected]:username/BBB.git because the settings are still trying to "push" to [email protected]:username/AAA.git but I need to push to [email protected]:username/BBB.git now.

How could I do that?

Cheers!

Sammy

A: 

Why not pull your new repository on your local machine as BBB and then merge them on your local machine and push BBB back to git. Then delete AAA.

Nick Gorbikoff
A: 

Take a look in .git/config and make the changes you need.

Alternatively you could use

git remote rm

and

git remote add

Before you do anything wrong, double check with

git help remote
Styggentorsken
+4  A: 

The easiest way to tweak this imho is to edit the .git/config file in your repository. Look for the entry you messed up and just tweak the URL.

On my machine in a repo I reguarlly use it looks like this:

KidA% cat .git/config 
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    autocflg = true
[remote "origin"]
    url = ssh://localhost:8888/opt/local/var/git/project.git
    #url = ssh://xxx.xxx.xxx.xxx:80/opt/local/var/git/project.git
    fetch = +refs/heads/*:refs/remotes/origin/*

The line you see commented out is an alternative address for the repository that I sometimes switch to simply by changing which line is commented out.

This is the file that is getting manipulated under-the-hood when you run something like git remote rm or git remote add but in this case since its only a typo you made it might make sense to correct it this way.

jkp