{"thread":{"id":"44338","subject":"How to rename remote branches if I only have \"client access\"?","startedAt":"2016-10-20T15:04:38Z","lastAt":"2016-10-20T15:56:02Z","messageCount":2,"participants":["Manuel Reimer","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"304467","messageId":"nuamc4$uvk$1@blaine.gmane.org","threadId":"44338","inReplyTo":null,"subject":"How to rename remote branches if I only have \"client access\"?","fromName":"Manuel Reimer","fromEmail":"manuel.spam@nurfuerspam.de","sentAt":"2016-10-20T15:03:35Z","receivedAt":"2016-10-20T15:04:38Z","isPatch":false,"sender":{"key":"manuel.spam@nurfuerspam.de","avatar":null},"body":"Hello,\n\nI have the following branches on my remote repo:\n\nnew_version\nmaster\n\nI now want the \"new_version\" branch to be the \"master\" and the old \n\"master\" has to be renamed to the old version number (in my case 0.2.0).\n\nHow to do this? Currently this causes me much trouble as I can't delete \nthe remote \"master\" repository as this is the \"remote current repository\"...\n\nThanks in advance\n\nManuel\n\n"},{"id":"304469","messageId":"xmqqr37bhv5k.fsf@gitster.mtv.corp.google.com","threadId":"44338","inReplyTo":"nuamc4$uvk$1@blaine.gmane.org","subject":"Re: How to rename remote branches if I only have \"client access\"?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-10-20T15:55:51Z","receivedAt":"2016-10-20T15:56:02Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Manuel Reimer <Manuel.Spam@nurfuerspam.de> writes:\n\n> I have the following branches on my remote repo:\n>\n> new_version\n> master\n>\n> I now want the \"new_version\" branch to be the \"master\" and the old\n> \"master\" has to be renamed to the old version number (in my case\n> 0.2.0).\n>\n> How to do this? \n\nI assume you have \"git push\" access into this remote repository.\n\nYou are correct that there is no way for you to tell \"git push\" (or\nany Git native method) to rename \"master\" to \"maint-0.2.0\".\n\nWhat you can do is to push the commits at the tip of \"master\" and\n\"new_version\" to \"maint-0.2.0\" and \"master\" respectively, and then\ndelete \"new_version\".  If the 'master' and 'new_version' you locally\nhave are already the 'master' and 'new_version' you have over there\nthat you want to see sit at the tips of updated 'maint-0.2.0' and\n'master' branches, then:\n\n    git push $remote master:refs/heads/maint-0.2.0 new_version:master\n    git push $remote :new_version\n\nwould do this.\n\nNote that in the <source>:<dest> syntax in \"git push\", the <source>\nside refers to the names in your local repository; if your local\n'master' is different from what you want to see at the tip of\n'maint-0.2.0' at the remote after this, replace it with whatever\nname you give to that commit locally in the above example.\n\nAlso note that the this push may not succeed if your new_version is\nnot a descendant of the current 'master' at the remote.  You'd need\nto use +<source>:<dest> to force it if that is the case.\n\nThe second command that has an empty <source> is to delete <dest>.\n\nLastly, the remote side can be configured to forbid deletion of\nbranches, and/or to forbid forced pushes.  If your remote is\nconfigured that way (which is not default), then there is no way for\nyou to do any of the above (and that is by design---the server\noperators use these configuration variables to forbid you from doing\nsomething, so you shouldn't be able to override that choice).\n\n> Currently this causes me much trouble as I can't\n> delete the remote \"master\" repository as this is the \"remote current\n> repository\"...\n\nSorry, but you lost me here. You were talking about two branches in\na single repository that is remote earlier.  I do not know what this\n\"remote master repository\" you bring up in this paragraph is, and\nwhy you can't remove it.  Not that I want to know the answers to\nthese questions myself.  I just do not understand these as a reason\nbehind your wanting to rename branches at a remote repository.\n"}]}