{"thread":{"id":"22089","subject":"A question about changing remote repo name","startedAt":"2010-01-04T06:45:09Z","lastAt":"2010-01-07T01:53:19Z","messageCount":14,"participants":["Dongas","Miklos Vajna","Erik Faye-Lund","Russell Steicke","David Aguilar","Johannes Schindelin","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"130749","messageId":"60ce8d251001032245n4e0267b1o1ecc796f324f8179@mail.gmail.com","threadId":"22089","inReplyTo":null,"subject":"A question about changing remote repo name","fromName":"Dongas","fromEmail":"dongas86@gmail.com","sentAt":"2010-01-04T06:45:09Z","receivedAt":"2010-01-04T06:45:09Z","isPatch":false,"sender":{"key":"dongas86@gmail.com","avatar":null},"body":"Hi ALL,\n\nI'm running ubuntu 9.04 and the git coming along with it doesn't\nsupport git remote rename command.\nBelow is the man page of it:\nGIT-REMOTE(1)\n                                        Git Manual\n\n     GIT-REMOTE(1)\n\nNAME\n       git-remote - manage set of tracked repositories\n\nSYNOPSIS\n           git remote [-v | --verbose]\n           git remote add [-t <branch>] [-m <master>] [-f] [--mirror]\n<name> <url>\n           git remote rm <name>\n           git remote show [-n] <name>\n           git remote prune [-n | --dry-run] <name>\n           git remote update [group]\nNote: There's no rename option.\n\nSo i need to change the remote name manually.\n\nI tried modifying the .git/config file locally but it didn't work.\n\nCould someone help tell how to do it?\n\nThanks\n\nRegards\nDongas\n"},{"id":"130793","messageId":"20100104200908.GS29803@genesis.frugalware.org","threadId":"22089","inReplyTo":"60ce8d251001032245n4e0267b1o1ecc796f324f8179@mail.gmail.com","subject":"Re: A question about changing remote repo name","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2010-01-04T20:09:09Z","receivedAt":"2010-01-04T20:09:09Z","isPatch":false,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Mon, Jan 04, 2010 at 02:45:09PM +0800, Dongas <dongas86@gmail.com> wrote:\n> I'm running ubuntu 9.04 and the git coming along with it doesn't\n> support git remote rename command.\n\nIt first appeared in v1.6.1, about a year ago. What does 'git version'\nsay?\n"},{"id":"130803","messageId":"60ce8d251001041753y5fe37b9do8d4cffc477e58198@mail.gmail.com","threadId":"22089","inReplyTo":"20100104200908.GS29803@genesis.frugalware.org","subject":"Re: A question about changing remote repo name","fromName":"Dongas","fromEmail":"dongas86@gmail.com","sentAt":"2010-01-05T01:53:41Z","receivedAt":"2010-01-05T01:53:41Z","isPatch":false,"sender":{"key":"dongas86@gmail.com","avatar":null},"body":"2010/1/5 Miklos Vajna <vmiklos@frugalware.org>:\n> On Mon, Jan 04, 2010 at 02:45:09PM +0800, Dongas <dongas86@gmail.com> wrote:\n>> I'm running ubuntu 9.04 and the git coming along with it doesn't\n>> support git remote rename command.\n>\n> It first appeared in v1.6.1, about a year ago. What does 'git version'\n> say?\n\nThanks a lot for your reply.\n\n# git --version\ngit version 1.6.0.4\n\nIt seems the ubuntu9.04 doesn't have the repo source to update to a\nhigher git version than 1.6.0.4,\ni'd like to know if there's a manual way to rename the git remote name\nwith this version.\n\nRegards\nDongas\n"},{"id":"130805","messageId":"40aa078e1001041757q137c9d1erf8f6793016d6a2c2@mail.gmail.com","threadId":"22089","inReplyTo":"60ce8d251001041753y5fe37b9do8d4cffc477e58198@mail.gmail.com","subject":"Re: A question about changing remote repo name","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2010-01-05T01:57:27Z","receivedAt":"2010-01-05T01:57:27Z","isPatch":false,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Tue, Jan 5, 2010 at 2:53 AM, Dongas <dongas86@gmail.com> wrote:\n> 2010/1/5 Miklos Vajna <vmiklos@frugalware.org>:\n>> On Mon, Jan 04, 2010 at 02:45:09PM +0800, Dongas <dongas86@gmail.com> wrote:\n>>> I'm running ubuntu 9.04 and the git coming along with it doesn't\n>>> support git remote rename command.\n>>\n>> It first appeared in v1.6.1, about a year ago. What does 'git version'\n>> say?\n>\n> Thanks a lot for your reply.\n>\n> # git --version\n> git version 1.6.0.4\n>\n> It seems the ubuntu9.04 doesn't have the repo source to update to a\n> higher git version than 1.6.0.4,\n> i'd like to know if there's a manual way to rename the git remote name\n> with this version.\n>\n\nI know this isn't REALLY answering your question, but you should\nseriously consider upgrading. 1.6.0.4 is ancient.\n\n-- \nErik \"kusma\" Faye-Lund\n"},{"id":"130808","messageId":"60ce8d251001041825i1bc85b19u201b7ccce0f0c29b@mail.gmail.com","threadId":"22089","inReplyTo":"40aa078e1001041757q137c9d1erf8f6793016d6a2c2@mail.gmail.com","subject":"Re: A question about changing remote repo name","fromName":"Dongas","fromEmail":"dongas86@gmail.com","sentAt":"2010-01-05T02:25:34Z","receivedAt":"2010-01-05T02:25:34Z","isPatch":false,"sender":{"key":"dongas86@gmail.com","avatar":null},"body":"2010/1/5 Erik Faye-Lund <kusmabite@googlemail.com>:\n> On Tue, Jan 5, 2010 at 2:53 AM, Dongas <dongas86@gmail.com> wrote:\n>> 2010/1/5 Miklos Vajna <vmiklos@frugalware.org>:\n>>> On Mon, Jan 04, 2010 at 02:45:09PM +0800, Dongas <dongas86@gmail.com> wrote:\n>>>> I'm running ubuntu 9.04 and the git coming along with it doesn't\n>>>> support git remote rename command.\n>>>\n>>> It first appeared in v1.6.1, about a year ago. What does 'git version'\n>>> say?\n>>\n>> Thanks a lot for your reply.\n>>\n>> # git --version\n>> git version 1.6.0.4\n>>\n>> It seems the ubuntu9.04 doesn't have the repo source to update to a\n>> higher git version than 1.6.0.4,\n>> i'd like to know if there's a manual way to rename the git remote name\n>> with this version.\n>>\n>\n> I know this isn't REALLY answering your question, but you should\n> seriously consider upgrading. 1.6.0.4 is ancient.\n>\nThanks a lot for your advices.\nUnfortunately, all my team members are running ubuntu 9.04.\nIf i could find a easy way to upgrade it, it will take it.\n\nRegards\nDongas\n"},{"id":"130809","messageId":"c1b8b6671001041852w4740b7d6g4b8db1221c5dc744@mail.gmail.com","threadId":"22089","inReplyTo":"60ce8d251001032245n4e0267b1o1ecc796f324f8179@mail.gmail.com","subject":"Re: A question about changing remote repo name","fromName":"Russell Steicke","fromEmail":"russellsteicke@gmail.com","sentAt":"2010-01-05T02:52:46Z","receivedAt":"2010-01-05T02:52:46Z","isPatch":false,"sender":{"key":"russellsteicke@gmail.com","avatar":null},"body":"On Mon, Jan 4, 2010 at 2:45 PM, Dongas <dongas86@gmail.com> wrote:\n> So i need to change the remote name manually.\n>\n> I tried modifying the .git/config file locally but it didn't work.\n>\n> Could someone help tell how to do it?\n\nAfter editing .git/config, do this:\n\n$ mv .git/refs/remotes/OLDNAME .git/refs/remotes/NEWNAME\n\nand optionally:\n\n$ mv .git/logs/refs/remotes/OLDNAME .git/logs/refs/remotes/NEWNAME\n\nRemember to rename the remote in any tracking branches in .git/config,\nas well as the name in the [remote \"OLDNAME\"] section, and the name in\nany fetch and push lines.  ie\n\n[remote \"OLDNAME\"]\n\turl = something\n\tfetch = +refs/heads/*:refs/remotes/OLDNAME/*\n[branch \"master\"]\n\tremote = OLDNAME\n\tmerge = refs/heads/master\n\nBecomes\n\n[remote \"NEWNAME\"]\n\turl = something\n\tfetch = +refs/heads/*:refs/remotes/NEWNAME/*\n[branch \"master\"]\n\tremote = NEWNAME\n\tmerge = refs/heads/master\n\n\n\n\n\n-- \nVirus found in this message.\n"},{"id":"130812","messageId":"60ce8d251001042030l75c5443gf173f127ad206df3@mail.gmail.com","threadId":"22089","inReplyTo":"c1b8b6671001041852w4740b7d6g4b8db1221c5dc744@mail.gmail.com","subject":"Re: A question about changing remote repo name","fromName":"Dongas","fromEmail":"dongas86@gmail.com","sentAt":"2010-01-05T04:30:03Z","receivedAt":"2010-01-05T04:30:03Z","isPatch":false,"sender":{"key":"dongas86@gmail.com","avatar":null},"body":"2010/1/5 Russell Steicke <russellsteicke@gmail.com>:\n> On Mon, Jan 4, 2010 at 2:45 PM, Dongas <dongas86@gmail.com> wrote:\n>> So i need to change the remote name manually.\n>>\n>> I tried modifying the .git/config file locally but it didn't work.\n>>\n>> Could someone help tell how to do it?\n>\n> After editing .git/config, do this:\n>\n> $ mv .git/refs/remotes/OLDNAME .git/refs/remotes/NEWNAME\n>\n> and optionally:\n>\n> $ mv .git/logs/refs/remotes/OLDNAME .git/logs/refs/remotes/NEWNAME\n>\n> Remember to rename the remote in any tracking branches in .git/config,\n> as well as the name in the [remote \"OLDNAME\"] section, and the name in\n> any fetch and push lines.  ie\n>\n> [remote \"OLDNAME\"]\n>        url = something\n>        fetch = +refs/heads/*:refs/remotes/OLDNAME/*\n> [branch \"master\"]\n>        remote = OLDNAME\n>        merge = refs/heads/master\n>\n> Becomes\n>\n> [remote \"NEWNAME\"]\n>        url = something\n>        fetch = +refs/heads/*:refs/remotes/NEWNAME/*\n> [branch \"master\"]\n>        remote = NEWNAME\n>        merge = refs/heads/master\n\nThanks a lot, Russell.\nI followed you instruction but it seemed it needs more changes.\n\nBelow are the steps:\nOriginal:\nroot@ubuntu:/work/git-repo/free_monkey# tree -a\n.\n|-- .git\n|   |-- HEAD\n|   |-- branches\n|   |-- config\n|   |-- description\n|   |-- hooks\n|   |   |-- applypatch-msg.sample\n|   |   |-- commit-msg.sample\n|   |   |-- post-commit.sample\n|   |   |-- post-receive.sample\n|   |   |-- post-update.sample\n|   |   |-- pre-applypatch.sample\n|   |   |-- pre-commit.sample\n|   |   |-- pre-rebase.sample\n|   |   |-- prepare-commit-msg.sample\n|   |   `-- update.sample\n|   |-- index\n|   |-- info\n|   |   `-- exclude\n|   |-- logs\n|   |   |-- HEAD\n|   |   `-- refs\n|   |       |-- heads\n|   |       |   `-- master\n|   |       `-- remotes\n|   |           `-- origin\n|   |               `-- HEAD\n|   |-- objects\n|   |   |-- info\n|   |   `-- pack\n|   |       |-- pack-f4beae76253ca8d36af31c42320462b5cf4940fc.idx\n|   |       `-- pack-f4beae76253ca8d36af31c42320462b5cf4940fc.pack\n|   |-- packed-refs\n|   `-- refs\n|       |-- heads\n|       |   `-- master\n|       |-- remotes\n|       |   `-- origin\n|       |       `-- HEAD\n|       `-- tags\n`-- hello1\n\nroot@ubuntu:/work/git-repo/free_monkey# cat .git/config\n[core]\n\trepositoryformatversion = 0\n\tfilemode = true\n\tbare = false\n\tlogallrefupdates = true\n[remote \"origin\"]\n\turl = git@192.168.1.116:free_monkey.git\n\tfetch = +refs/heads/*:refs/remotes/origin/*\n[branch \"master\"]\n\tremote = origin\n\tmerge = refs/heads/master\nroot@ubuntu:/work/git-repo/free_monkey#\n\nExecute your steps....\nBecomes:\nroot@ubuntu:/work/git-repo/free_monkey# tree -a\n.\n|-- .git\n|   |-- HEAD\n|   |-- branches\n|   |-- config\n|   |-- description\n|   |-- hooks\n|   |   |-- applypatch-msg.sample\n|   |   |-- commit-msg.sample\n|   |   |-- post-commit.sample\n|   |   |-- post-receive.sample\n|   |   |-- post-update.sample\n|   |   |-- pre-applypatch.sample\n|   |   |-- pre-commit.sample\n|   |   |-- pre-rebase.sample\n|   |   |-- prepare-commit-msg.sample\n|   |   `-- update.sample\n|   |-- index\n|   |-- info\n|   |   `-- exclude\n|   |-- logs\n|   |   |-- HEAD\n|   |   `-- refs\n|   |       |-- heads\n|   |       |   `-- master\n|   |       `-- remotes\n|   |           `-- karmic\n|   |               `-- HEAD\n|   |-- objects\n|   |   |-- info\n|   |   `-- pack\n|   |       |-- pack-f4beae76253ca8d36af31c42320462b5cf4940fc.idx\n|   |       `-- pack-f4beae76253ca8d36af31c42320462b5cf4940fc.pack\n|   |-- packed-refs\n|   `-- refs\n|       |-- heads\n|       |   `-- master\n|       |-- remotes\n|       |   `-- karmic\n|       |       `-- HEAD\n|       `-- tags\n`-- hello1\n\nroot@ubuntu:/work/git-repo/free_monkey# cat .git/config\n[core]\n\trepositoryformatversion = 0\n\tfilemode = true\n\tbare = false\n\tlogallrefupdates = true\n[remote \"karmic\"]\n\turl = git@192.168.1.116:free_monkey.git\n\tfetch = +refs/heads/*:refs/remotes/karmic/*\n[branch \"master\"]\n\tremote = karmic\n\tmerge = refs/heads/master\n\nBut the result was:\nroot@ubuntu:/work/git-repo/free_monkey# git branch -a\n* master\n  karmic/HEAD\n  origin/master\nThe 'origin/master' was still not changed.\n\nI did a few more steps:\nroot@ubuntu:/work/git-repo/free_monkey# grep -wrin 'origin' .\n./.git/packed-refs:2:abfae429bb4081043e84681e5ee94102085f87e0\nrefs/remotes/origin/master\n./.git/refs/remotes/karmic/HEAD:1:ref: refs/remotes/origin/master\n\nChange 'origin' to 'karmic' in above files.\n\nThen,\nroot@ubuntu:/work/git-repo/free_monkey# git branch -a\n* master\n  karmic/HEAD\n  karmic/master\n\nThe steps are a little complicated.\nDo you know if there's a way to rename the remote on server side?\nIf there is, then everyone could just clone the project with a new\nremote name rather than the defaul 'origin'.\n\n\nThanks\n\nRegards\nDongas\n"},{"id":"130863","messageId":"20100105211521.GC2657@gmail.com","threadId":"22089","inReplyTo":"60ce8d251001042030l75c5443gf173f127ad206df3@mail.gmail.com","subject":"Re: A question about changing remote repo name","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2010-01-05T21:15:23Z","receivedAt":"2010-01-05T21:15:23Z","isPatch":false,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"\nHi,\n\nOn Tue, Jan 05, 2010 at 12:30:03PM +0800, Dongas wrote:\n> 2010/1/5 Russell Steicke <russellsteicke@gmail.com>:\n> > On Mon, Jan 4, 2010 at 2:45 PM, Dongas <dongas86@gmail.com> wrote:\n> \n> Thanks a lot, Russell.\n> I followed you instruction but it seemed it needs more changes.\n> \n> Execute your steps....\n> Becomes:\n> root@ubuntu:/work/git-repo/free_monkey# tree -a\n\nJust a note: I would recommend against being root.\nYou cloned the repo so you should own it.\n\nMore below...\n\n\n> root@ubuntu:/work/git-repo/free_monkey# cat .git/config\n> [core]\n> \trepositoryformatversion = 0\n> \tfilemode = true\n> \tbare = false\n> \tlogallrefupdates = true\n> [remote \"karmic\"]\n> \turl = git@192.168.1.116:free_monkey.git\n> \tfetch = +refs/heads/*:refs/remotes/karmic/*\n> [branch \"master\"]\n> \tremote = karmic\n> \tmerge = refs/heads/master\n> \n> But the result was:\n> root@ubuntu:/work/git-repo/free_monkey# git branch -a\n> * master\n>   karmic/HEAD\n>   origin/master\n> The 'origin/master' was still not changed.\n\n\nA safter alternative would be to leave the \"origin\" lines in\nplace as a duplicate of karmic:\n\n[remote \"karmic\"]\n\turl = git@192.168.1.116:free_monkey.git\n\tfetch = +refs/heads/*:refs/karmic/origin/*\n\n[remote \"origin\"]\n\turl = git@192.168.1.116:free_monkey.git\n\tfetch = +refs/heads/*:refs/remotes/origin/*\n\n\nAt that point you will have two remotes, \"karmic\" and \"origin\".\n\"git fetch karmic\" to get the latest branches.\n\nFinally, \"git remote rm origin\" to remove all references to it.\n\n> I did a few more steps:\n> root@ubuntu:/work/git-repo/free_monkey# grep -wrin 'origin' .\n> ./.git/packed-refs:2:abfae429bb4081043e84681e5ee94102085f87e0\n> refs/remotes/origin/master\n> ./.git/refs/remotes/karmic/HEAD:1:ref: refs/remotes/origin/master\n> \n> Change 'origin' to 'karmic' in above files.\n\n\nYou can skip this step by using \"git remote rm\" as described\nabove.\n\n\n> The steps are a little complicated.\n> Do you know if there's a way to rename the remote on server side?\n> If there is, then everyone could just clone the project with a new\n> remote name rather than the defaul 'origin'.\n\nUnfortunately, no.  \"origin\" is actually a local thing.\nYour local git client gives it that name.  As you can see, the\nremote does not care whether we call it \"origin\" or \"karmic\".\n\n\nThere were some patches flying around on the ML some time ago\nthat allowed you to change the default \"origin\" name on the\nclient side at \"git clone\" time (or maybe patches never\nmaterialized and it was purely discussion).\n\nThat was a while ago (probably over a year ago) and this wasn't\nanybody's itch to scratch in the meantime so nothing every\nmaterialized.  It think this is only the 2nd time this has come\nup in that whole time.  Sorry, I wasn't able to find the thread.\n\n\nHere's a nice middle ground --\n\ninstead of naming your branch \"master\" you can call your default\nbranch \"karmic\".\n\nTo make it the default for \"git clone\" then you'll need to push\nyour local master branch and call it \"karmic\" over there:\n\n\tgit push origin master:karmic\n\nThen, go to that server and change the repo's HEAD entry so that\nit points to karmic instead of master.\n\n\tssh admin@gitbox\n\tcd /path/to/repo.git\n\tvi HEAD\n\n>From then on, everyone who clones the repo will have a \"karmic\"\nbranch by default instead of the master branch.\n\nTo get that branch on repos that were cloned before the change:\n\n\tgit fetch origin\n\tgit checkout -b karmic origin/karmic\n\n\n\nWith this setup you might even want to remove the \"master\"\nbranch altogether since it might be confusing to have both:\n\nOnce:\n\tgit push origin :master\n\nIn everyone's repo:\n\tgit remote prune origin\n\n\nYou will need to make sure everyone has either:\n\ta) cloned from the new master-less repo\n\tb) run the \"checkout -b\" and \"remote prune\" commands\n\nOtherwise someone'll likely \"git push\" the master branch back\ninto existence.\n\n\n-- \n\t\tDavid\n"},{"id":"130875","messageId":"c1b8b6671001051607j6b6398d8gf08f7615a38de64e@mail.gmail.com","threadId":"22089","inReplyTo":"60ce8d251001042030l75c5443gf173f127ad206df3@mail.gmail.com","subject":"Re: A question about changing remote repo name","fromName":"Russell Steicke","fromEmail":"russellsteicke@gmail.com","sentAt":"2010-01-06T00:07:48Z","receivedAt":"2010-01-06T00:07:48Z","isPatch":false,"sender":{"key":"russellsteicke@gmail.com","avatar":null},"body":"On Tue, Jan 5, 2010 at 12:30 PM, Dongas <dongas86@gmail.com> wrote:\n> I did a few more steps:\n> root@ubuntu:/work/git-repo/free_monkey# grep -wrin 'origin' .\n> ./.git/packed-refs:2:abfae429bb4081043e84681e5ee94102085f87e0\n> refs/remotes/origin/master\n> ./.git/refs/remotes/karmic/HEAD:1:ref: refs/remotes/origin/master\n>\n> Change 'origin' to 'karmic' in above files.\n\nAh yes, I forgot about those files.  I _think_ (but I'm not certain\nwithout digging into the code) that it's always safe to rm\npacked-refs, as that file is a cache for quicker access to the refs.\nAt least it's never caused me any problems.\n\nIn any case, your approach of grepping the whole of .git for\ninteresting strings is a good way to learn about the implementation.\n\n\n-- \nVirus found in this message.\n"},{"id":"130876","messageId":"alpine.DEB.1.00.1001060123280.4985@pacific.mpi-cbg.de","threadId":"22089","inReplyTo":"c1b8b6671001051607j6b6398d8gf08f7615a38de64e@mail.gmail.com","subject":"Re: A question about changing remote repo name","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2010-01-06T00:27:03Z","receivedAt":"2010-01-06T00:27:03Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 6 Jan 2010, Russell Steicke wrote:\n\n> On Tue, Jan 5, 2010 at 12:30 PM, Dongas <dongas86@gmail.com> wrote:\n> > I did a few more steps:\n> > root@ubuntu:/work/git-repo/free_monkey# grep -wrin 'origin' .\n> > ./.git/packed-refs:2:abfae429bb4081043e84681e5ee94102085f87e0\n> > refs/remotes/origin/master\n> > ./.git/refs/remotes/karmic/HEAD:1:ref: refs/remotes/origin/master\n> >\n> > Change 'origin' to 'karmic' in above files.\n> \n> Ah yes, I forgot about those files.  I _think_ (but I'm not certain\n> without digging into the code) that it's always safe to rm\n> packed-refs, as that file is a cache for quicker access to the refs.\n\nFor everybody reading this thread: DON'T!\n\nRussel, it would be better if you knew about the mechanism before \nmaking other people believe that it is safe to delete a file that is _not_ \na cache, but _replaces_ the existing refs.\n\n(Just mentioning that you only _think_ it is safe does not help; it is not \nsafe, but people will think that it is safe.  Maybe you'll spend those 5 \nminutes in the future before sending a message like you did...)\n\nHth,\nDscho\n"},{"id":"130877","messageId":"7vd41oqc3h.fsf@alter.siamese.dyndns.org","threadId":"22089","inReplyTo":"c1b8b6671001051607j6b6398d8gf08f7615a38de64e@mail.gmail.com","subject":"Re: A question about changing remote repo name","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-01-06T01:02:58Z","receivedAt":"2010-01-06T01:02:58Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Russell Steicke <russellsteicke@gmail.com> writes:\n\n> Ah yes, I forgot about those files.  I _think_ (but I'm not certain\n> without digging into the code) that it's always safe to rm\n> packed-refs, as that file is a cache for quicker access to the refs.\n\nNo what you think is incorrect, no it is not safe at all, and no it is not\na cache.\n\nrefs are created loose as files under $GIT_DIR/refs/.  When pack-refs is\nrun (either from the toplevel or as part of gc), these loose ref files are\nremoved and instead written to $GIT_DIR/packed-refs file.  When a new ref\nis created or an existing ref is updated, only $GIT_DIR/refs/ is modified.\n\nWhen reading or enumerating, a loose ref, if found, is used.  Otherwise\na record in packed-refs is consulted.  The consequences are:\n\n - If you have $GIT_DIR/refs/heads/master and at the same time, an entry\n   for refs/heads/master exists in $GIT_DIR/packed-refs, removing the\n   entry in packed-refs happens to be safe, because it was already masked.\n\n - If you do not have $GIT_DIR/refs/heads/old, but an entry for\n   refs/heads/old exists in $GIT_DIR/packed-refs, removing the entry in\n   packed-refs means you lose the \"old\" branch.  You don't want to do\n   that.\n\n - When deleting a ref, we remove it from $GIT_DIR/refs/, but at the same\n   time, if packed-refs contains an entry for it, we remove it from\n   there.  Otherwise, the removal of the loose one will unmask the stale\n   entry in packed-refs file.\n"},{"id":"130891","messageId":"60ce8d251001051955x117df3c8t5de7972ce5632c7@mail.gmail.com","threadId":"22089","inReplyTo":"20100105211521.GC2657@gmail.com","subject":"Re: A question about changing remote repo name","fromName":"Dongas","fromEmail":"dongas86@gmail.com","sentAt":"2010-01-06T03:55:52Z","receivedAt":"2010-01-06T03:55:52Z","isPatch":false,"sender":{"key":"dongas86@gmail.com","avatar":null},"body":"2010/1/6 David Aguilar <davvid@gmail.com>:\n>\n> Hi,\n>\n> On Tue, Jan 05, 2010 at 12:30:03PM +0800, Dongas wrote:\n>> 2010/1/5 Russell Steicke <russellsteicke@gmail.com>:\n>> > On Mon, Jan 4, 2010 at 2:45 PM, Dongas <dongas86@gmail.com> wrote:\n>>\n>> Thanks a lot, Russell.\n>> I followed you instruction but it seemed it needs more changes.\n>>\n>> Execute your steps....\n>> Becomes:\n>> root@ubuntu:/work/git-repo/free_monkey# tree -a\n>\n> Just a note: I would recommend against being root.\n> You cloned the repo so you should own it.\n\nThanks for your advices.\n\n> More below...\n>\n>\n>> root@ubuntu:/work/git-repo/free_monkey# cat .git/config\n>> [core]\n>>       repositoryformatversion = 0\n>>       filemode = true\n>>       bare = false\n>>       logallrefupdates = true\n>> [remote \"karmic\"]\n>>       url = git@192.168.1.116:free_monkey.git\n>>       fetch = +refs/heads/*:refs/remotes/karmic/*\n>> [branch \"master\"]\n>>       remote = karmic\n>>       merge = refs/heads/master\n>>\n>> But the result was:\n>> root@ubuntu:/work/git-repo/free_monkey# git branch -a\n>> * master\n>>   karmic/HEAD\n>>   origin/master\n>> The 'origin/master' was still not changed.\n>\n>\n> A safter alternative would be to leave the \"origin\" lines in\n> place as a duplicate of karmic:\n>\n> [remote \"karmic\"]\n>        url = git@192.168.1.116:free_monkey.git\n>        fetch = +refs/heads/*:refs/karmic/origin/*\n>\n> [remote \"origin\"]\n>        url = git@192.168.1.116:free_monkey.git\n>        fetch = +refs/heads/*:refs/remotes/origin/*\n>\n>\n> At that point you will have two remotes, \"karmic\" and \"origin\".\n> \"git fetch karmic\" to get the latest branches.\n>\n> Finally, \"git remote rm origin\" to remove all references to it.\n\nIt's a good idea.\nI have tried and it seemed to work.\n(I also did a few more works to make it better)\n\nBelow is the result:\nroot@ubuntu:/work/git-repo/tmp/free_monkey# git branch -a\n* master\n  origin/HEAD\n  origin/master\nroot@ubuntu:/work/git-repo/tmp/free_monkey# cat .git/config\n[core]\n\trepositoryformatversion = 0\n\tfilemode = true\n\tbare = false\n\tlogallrefupdates = true\n[remote \"origin\"]\n\turl = git@192.168.1.106:free_monkey.git\n\tfetch = +refs/heads/*:refs/remotes/origin/*\n[branch \"master\"]\n\tremote = origin\n\tmerge = refs/heads/master\nroot@ubuntu:/work/git-repo/tmp/free_monkey# git remote add karmic\ngit@192.168.1.106:free_monkey.git\nroot@ubuntu:/work/git-repo/tmp/free_monkey# git fetch karmic\nFrom git@192.168.1.106:free_monkey\n * [new branch]      master     -> karmic/master\nroot@ubuntu:/work/git-repo/tmp/free_monkey# git branch -a\n* master\n  karmic/master\n  origin/HEAD\n  origin/master\nroot@ubuntu:/work/git-repo/tmp/free_monkey# git remote rm origin\nroot@ubuntu:/work/git-repo/tmp/free_monkey# git branch -a\n* master\n  karmic/master\n\nHowever there's a little issue:\nroot@ubuntu:/work/git-repo/tmp/free_monkey# git pull\nfatal: 'origin': unable to chdir or not a git archive\nfatal: The remote end hung up unexpectedly\nroot@ubuntu:/work/git-repo/tmp/free_monkey# grep -wrin 'origin' .git/\nroot@ubuntu:/work/git-repo/tmp/free_monkey# cat .git/config\n[core]\n\trepositoryformatversion = 0\n\tfilemode = true\n\tbare = false\n\tlogallrefupdates = true\n[branch \"master\"]\n[remote \"karmic\"]\n\turl = git@192.168.1.106:free_monkey.git\n\tfetch = +refs/heads/*:refs/remotes/karmic/*\n\nBut 'git pull karmic master' worked well.\nroot@ubuntu:/work/git-repo/tmp/free_monkey# git pull karmic master\nFrom git@192.168.1.106:free_monkey\n * branch            master     -> FETCH_HEAD\nAlready up-to-date.\n\nFor conveniently, i did a few more steps.\nAdd two lines below '[branch \"master\"]':\nroot@ubuntu:/work/git-repo/tmp/free_monkey# cat .git/config\n[core]\n\trepositoryformatversion = 0\n\tfilemode = true\n\tbare = false\n\tlogallrefupdates = true\n[branch \"master\"]\n\tremote = karmic\n\tmerge = refs/heads/master\n[remote \"karmic\"]\n\turl = git@192.168.1.106:free_monkey.git\n\tfetch = +refs/heads/*:refs/remotes/karmic/*\nThen, 'git pull' worked well.\nroot@ubuntu:/work/git-repo/tmp/free_monkey# git pull\nAlready up-to-date.\n\n> That was a while ago (probably over a year ago) and this wasn't\n> anybody's itch to scratch in the meantime so nothing every\n> materialized.  It think this is only the 2nd time this has come\n> up in that whole time.  Sorry, I wasn't able to find the thread.\n\nThanks for the info.\n\n> Here's a nice middle ground --\n>\n> instead of naming your branch \"master\" you can call your default\n> branch \"karmic\".\n>\n> To make it the default for \"git clone\" then you'll need to push\n> your local master branch and call it \"karmic\" over there:\n>\n>        git push origin master:karmic\n>\n> Then, go to that server and change the repo's HEAD entry so that\n> it points to karmic instead of master.\n>\n>        ssh admin@gitbox\n>        cd /path/to/repo.git\n>        vi HEAD\n>\n> From then on, everyone who clones the repo will have a \"karmic\"\n> branch by default instead of the master branch.\n>\n> To get that branch on repos that were cloned before the change:\n>\n>        git fetch origin\n>        git checkout -b karmic origin/karmic\n>\n>\n>\n> With this setup you might even want to remove the \"master\"\n> branch altogether since it might be confusing to have both:\n>\n> Once:\n>        git push origin :master\n>\n> In everyone's repo:\n>        git remote prune origin\n>\n>\n> You will need to make sure everyone has either:\n>        a) cloned from the new master-less repo\n>        b) run the \"checkout -b\" and \"remote prune\" commands\n>\n> Otherwise someone'll likely \"git push\" the master branch back\n> into existence.\n\nThanks a lot for the alternative way , it looks good.\n\nRegards\nDongas\n"},{"id":"130890","messageId":"60ce8d251001051958p726e7dadp9a8a778a0e6c1b11@mail.gmail.com","threadId":"22089","inReplyTo":"c1b8b6671001051607j6b6398d8gf08f7615a38de64e@mail.gmail.com","subject":"Re: A question about changing remote repo name","fromName":"Dongas","fromEmail":"dongas86@gmail.com","sentAt":"2010-01-06T03:58:05Z","receivedAt":"2010-01-06T03:58:05Z","isPatch":false,"sender":{"key":"dongas86@gmail.com","avatar":null},"body":"2010/1/6 Russell Steicke <russellsteicke@gmail.com>:\n> On Tue, Jan 5, 2010 at 12:30 PM, Dongas <dongas86@gmail.com> wrote:\n>> I did a few more steps:\n>> root@ubuntu:/work/git-repo/free_monkey# grep -wrin 'origin' .\n>> ./.git/packed-refs:2:abfae429bb4081043e84681e5ee94102085f87e0\n>> refs/remotes/origin/master\n>> ./.git/refs/remotes/karmic/HEAD:1:ref: refs/remotes/origin/master\n>>\n>> Change 'origin' to 'karmic' in above files.\n>\n> Ah yes, I forgot about those files.  I _think_ (but I'm not certain\n> without digging into the code) that it's always safe to rm\n> packed-refs, as that file is a cache for quicker access to the refs.\n> At least it's never caused me any problems.\n>\n> In any case, your approach of grepping the whole of .git for\n> interesting strings is a good way to learn about the implementation.\n\nThanks a lot for your help. :)\n\nRegards\nDongas\n"},{"id":"130966","messageId":"c1b8b6671001061753h12d29511pa07bb080bd6c7834@mail.gmail.com","threadId":"22089","inReplyTo":"alpine.DEB.1.00.1001060123280.4985@pacific.mpi-cbg.de","subject":"Re: A question about changing remote repo name","fromName":"Russell Steicke","fromEmail":"russellsteicke@gmail.com","sentAt":"2010-01-07T01:53:19Z","receivedAt":"2010-01-07T01:53:19Z","isPatch":false,"sender":{"key":"russellsteicke@gmail.com","avatar":null},"body":"On Wed, Jan 6, 2010 at 8:27 AM, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n> For everybody reading this thread: DON'T!\n>\n> Russel, it would be better if you knew about the mechanism before\n> making other people believe that it is safe to delete a file that is _not_\n> a cache, but _replaces_ the existing refs.\n\nThank you for explaining that.  I apologise for the misleading information.\n\nI have seen refs in packed-refs as duplicates of those in the refs/\ntree.  How would that come about?\n\n\n\n-- \nVirus found in this message.\n"}]}