From: Dongas <dongas86@gmail.com>
To: David Aguilar <davvid@gmail.com>
Cc: Russell Steicke <russellsteicke@gmail.com>, git@vger.kernel.org
Subject: Re: A question about changing remote repo name
Date: Wed, 6 Jan 2010 11:55:52 +0800 [thread overview]
Message-ID: <60ce8d251001051955x117df3c8t5de7972ce5632c7@mail.gmail.com> (raw)
In-Reply-To: <20100105211521.GC2657@gmail.com>
2010/1/6 David Aguilar <davvid@gmail.com>:
>
> Hi,
>
> On Tue, Jan 05, 2010 at 12:30:03PM +0800, Dongas wrote:
>> 2010/1/5 Russell Steicke <russellsteicke@gmail.com>:
>> > On Mon, Jan 4, 2010 at 2:45 PM, Dongas <dongas86@gmail.com> wrote:
>>
>> Thanks a lot, Russell.
>> I followed you instruction but it seemed it needs more changes.
>>
>> Execute your steps....
>> Becomes:
>> root@ubuntu:/work/git-repo/free_monkey# tree -a
>
> Just a note: I would recommend against being root.
> You cloned the repo so you should own it.
Thanks for your advices.
> More below...
>
>
>> 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.
>
>
> A safter alternative would be to leave the "origin" lines in
> place as a duplicate of karmic:
>
> [remote "karmic"]
> url = git@192.168.1.116:free_monkey.git
> fetch = +refs/heads/*:refs/karmic/origin/*
>
> [remote "origin"]
> url = git@192.168.1.116:free_monkey.git
> fetch = +refs/heads/*:refs/remotes/origin/*
>
>
> At that point you will have two remotes, "karmic" and "origin".
> "git fetch karmic" to get the latest branches.
>
> Finally, "git remote rm origin" to remove all references to it.
It's a good idea.
I have tried and it seemed to work.
(I also did a few more works to make it better)
Below is the result:
root@ubuntu:/work/git-repo/tmp/free_monkey# git branch -a
* master
origin/HEAD
origin/master
root@ubuntu:/work/git-repo/tmp/free_monkey# cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = git@192.168.1.106:free_monkey.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
root@ubuntu:/work/git-repo/tmp/free_monkey# git remote add karmic
git@192.168.1.106:free_monkey.git
root@ubuntu:/work/git-repo/tmp/free_monkey# git fetch karmic
From git@192.168.1.106:free_monkey
* [new branch] master -> karmic/master
root@ubuntu:/work/git-repo/tmp/free_monkey# git branch -a
* master
karmic/master
origin/HEAD
origin/master
root@ubuntu:/work/git-repo/tmp/free_monkey# git remote rm origin
root@ubuntu:/work/git-repo/tmp/free_monkey# git branch -a
* master
karmic/master
However there's a little issue:
root@ubuntu:/work/git-repo/tmp/free_monkey# git pull
fatal: 'origin': unable to chdir or not a git archive
fatal: The remote end hung up unexpectedly
root@ubuntu:/work/git-repo/tmp/free_monkey# grep -wrin 'origin' .git/
root@ubuntu:/work/git-repo/tmp/free_monkey# cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[branch "master"]
[remote "karmic"]
url = git@192.168.1.106:free_monkey.git
fetch = +refs/heads/*:refs/remotes/karmic/*
But 'git pull karmic master' worked well.
root@ubuntu:/work/git-repo/tmp/free_monkey# git pull karmic master
From git@192.168.1.106:free_monkey
* branch master -> FETCH_HEAD
Already up-to-date.
For conveniently, i did a few more steps.
Add two lines below '[branch "master"]':
root@ubuntu:/work/git-repo/tmp/free_monkey# cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[branch "master"]
remote = karmic
merge = refs/heads/master
[remote "karmic"]
url = git@192.168.1.106:free_monkey.git
fetch = +refs/heads/*:refs/remotes/karmic/*
Then, 'git pull' worked well.
root@ubuntu:/work/git-repo/tmp/free_monkey# git pull
Already up-to-date.
> That was a while ago (probably over a year ago) and this wasn't
> anybody's itch to scratch in the meantime so nothing every
> materialized. It think this is only the 2nd time this has come
> up in that whole time. Sorry, I wasn't able to find the thread.
Thanks for the info.
> Here's a nice middle ground --
>
> instead of naming your branch "master" you can call your default
> branch "karmic".
>
> To make it the default for "git clone" then you'll need to push
> your local master branch and call it "karmic" over there:
>
> git push origin master:karmic
>
> Then, go to that server and change the repo's HEAD entry so that
> it points to karmic instead of master.
>
> ssh admin@gitbox
> cd /path/to/repo.git
> vi HEAD
>
> From then on, everyone who clones the repo will have a "karmic"
> branch by default instead of the master branch.
>
> To get that branch on repos that were cloned before the change:
>
> git fetch origin
> git checkout -b karmic origin/karmic
>
>
>
> With this setup you might even want to remove the "master"
> branch altogether since it might be confusing to have both:
>
> Once:
> git push origin :master
>
> In everyone's repo:
> git remote prune origin
>
>
> You will need to make sure everyone has either:
> a) cloned from the new master-less repo
> b) run the "checkout -b" and "remote prune" commands
>
> Otherwise someone'll likely "git push" the master branch back
> into existence.
Thanks a lot for the alternative way , it looks good.
Regards
Dongas
next prev parent reply other threads:[~2010-01-06 4:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-04 6:45 A question about changing remote repo name Dongas
2010-01-04 20:09 ` Miklos Vajna
2010-01-05 1:53 ` Dongas
2010-01-05 1:57 ` Erik Faye-Lund
2010-01-05 2:25 ` Dongas
2010-01-05 2:52 ` Russell Steicke
2010-01-05 4:30 ` Dongas
2010-01-05 21:15 ` David Aguilar
2010-01-06 3:55 ` Dongas [this message]
2010-01-06 0:07 ` Russell Steicke
2010-01-06 0:27 ` Johannes Schindelin
2010-01-07 1:53 ` Russell Steicke
2010-01-06 1:02 ` Junio C Hamano
2010-01-06 3:58 ` Dongas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=60ce8d251001051955x117df3c8t5de7972ce5632c7@mail.gmail.com \
--to=dongas86@gmail.com \
--cc=davvid@gmail.com \
--cc=git@vger.kernel.org \
--cc=russellsteicke@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).