git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: A question about changing remote repo name

From
DDongas <dongas86@gmail.com>
Date
Jan 5, 2010, 04:30 UTC
Message-ID
<60ce8d251001042030l75c5443gf173f127ad206df3@mail.gmail.com>
In-Reply-To
<c1b8b6671001041852w4740b7d6g4b8db1221c5dc744@mail.gmail.com>
2010/1/5 Russell Steicke <russellsteicke@gmail.com>:
Show 34 quoted lines
> On Mon, Jan 4, 2010 at 2:45 PM, Dongas <dongas86@gmail.com> wrote:
>> So i need to change the remote name manually.
>>
>> I tried modifying the .git/config file locally but it didn't work.
>>
>> Could someone help tell how to do it?
>
> After editing .git/config, do this:
>
> $ mv .git/refs/remotes/OLDNAME .git/refs/remotes/NEWNAME
>
> and optionally:
>
> $ mv .git/logs/refs/remotes/OLDNAME .git/logs/refs/remotes/NEWNAME
>
> Remember to rename the remote in any tracking branches in .git/config,
> as well as the name in the [remote "OLDNAME"] section, and the name in
> any fetch and push lines.  ie
>
> [remote "OLDNAME"]
>        url = something
>        fetch = +refs/heads/*:refs/remotes/OLDNAME/*
> [branch "master"]
>        remote = OLDNAME
>        merge = refs/heads/master
>
> Becomes
>
> [remote "NEWNAME"]
>        url = something
>        fetch = +refs/heads/*:refs/remotes/NEWNAME/*
> [branch "master"]
>        remote = NEWNAME
>        merge = refs/heads/master

Thanks a lot, Russell. I followed you instruction but it seemed it needs more changes.

Below are the steps:
Original:
root@ubuntu:/work/git-repo/free_monkey# tree -a
.
|-- .git
|   |-- HEAD
|   |-- branches
|   |-- config
|   |-- description
|   |-- hooks
|   |   |-- applypatch-msg.sample
|   |   |-- commit-msg.sample
|   |   |-- post-commit.sample
|   |   |-- post-receive.sample
|   |   |-- post-update.sample
|   |   |-- pre-applypatch.sample
|   |   |-- pre-commit.sample
|   |   |-- pre-rebase.sample
|   |   |-- prepare-commit-msg.sample
|   |   `-- update.sample
|   |-- index
|   |-- info
|   |   `-- exclude
|   |-- logs
|   |   |-- HEAD
|   |   `-- refs
|   |       |-- heads
|   |       |   `-- master
|   |       `-- remotes
|   |           `-- origin
|   |               `-- HEAD
|   |-- objects
|   |   |-- info
|   |   `-- pack
|   |       |-- pack-f4beae76253ca8d36af31c42320462b5cf4940fc.idx
|   |       `-- pack-f4beae76253ca8d36af31c42320462b5cf4940fc.pack
|   |-- packed-refs
|   `-- refs
|       |-- heads
|       |   `-- master
|       |-- remotes
|       |   `-- origin
|       |       `-- HEAD
|       `-- tags
`-- hello1
root@ubuntu:/work/git-repo/free_monkey# cat .git/config
[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
[remote "origin"]
	url = git@192.168.1.116:free_monkey.git
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
	remote = origin
	merge = refs/heads/master
root@ubuntu:/work/git-repo/free_monkey#
Execute your steps....
Becomes:
root@ubuntu:/work/git-repo/free_monkey# tree -a
.
|-- .git
|   |-- HEAD
|   |-- branches
|   |-- config
|   |-- description
|   |-- hooks
|   |   |-- applypatch-msg.sample
|   |   |-- commit-msg.sample
|   |   |-- post-commit.sample
|   |   |-- post-receive.sample
|   |   |-- post-update.sample
|   |   |-- pre-applypatch.sample
|   |   |-- pre-commit.sample
|   |   |-- pre-rebase.sample
|   |   |-- prepare-commit-msg.sample
|   |   `-- update.sample
|   |-- index
|   |-- info
|   |   `-- exclude
|   |-- logs
|   |   |-- HEAD
|   |   `-- refs
|   |       |-- heads
|   |       |   `-- master
|   |       `-- remotes
|   |           `-- karmic
|   |               `-- HEAD
|   |-- objects
|   |   |-- info
|   |   `-- pack
|   |       |-- pack-f4beae76253ca8d36af31c42320462b5cf4940fc.idx
|   |       `-- pack-f4beae76253ca8d36af31c42320462b5cf4940fc.pack
|   |-- packed-refs
|   `-- refs
|       |-- heads
|       |   `-- master
|       |-- remotes
|       |   `-- karmic
|       |       `-- HEAD
|       `-- tags
`-- hello1
root@ubuntu:/work/git-repo/free_monkey# cat .git/config
[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
[remote "karmic"]
	url = git@192.168.1.116:free_monkey.git
	fetch = +refs/heads/*:refs/remotes/karmic/*
[branch "master"]
	remote = karmic
	merge = refs/heads/master
But the result was:
root@ubuntu:/work/git-repo/free_monkey# git branch -a
* master
  karmic/HEAD
  origin/master
The 'origin/master' was still not changed.

I did a few more steps: root@ubuntu:/work/git-repo/free_monkey# grep -wrin 'origin' . ./.git/packed-refs:2:abfae429bb4081043e84681e5ee94102085f87e0 refs/remotes/origin/master ./.git/refs/remotes/karmic/HEAD:1:ref: refs/remotes/origin/master

Change 'origin' to 'karmic' in above files.
Then,
root@ubuntu:/work/git-repo/free_monkey# git branch -a
* master
  karmic/HEAD
  karmic/master

The steps are a little complicated. Do you know if there's a way to rename the remote on server side? If there is, then everyone could just clone the project with a new remote name rather than the defaul 'origin'.

Thanks

Regards Dongas

Previous: Russell SteickeNext: David Aguilar
Message 7 of 14 in “A question about changing remote repo name”
  1. DongasJan 4, 2010
  2. Miklos VajnaJan 4, 2010
  3. DongasJan 5, 2010
  4. Erik Faye-LundJan 5, 2010
  5. DongasJan 5, 2010
  6. Russell SteickeJan 5, 2010
  7. DongasJan 5, 2010
  8. David AguilarJan 5, 2010
  9. DongasJan 6, 2010
  10. Russell SteickeJan 6, 2010
  11. Johannes SchindelinJan 6, 2010
  12. Russell SteickeJan 7, 2010
  13. Junio C HamanoJan 6, 2010
  14. DongasJan 6, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.