{"thread":{"id":"25179","subject":"more useful set-upstream","startedAt":"2010-09-21T08:55:08Z","lastAt":"2010-09-21T09:30:25Z","messageCount":2,"participants":["Ramana Kumar","Matthieu Moy"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"151190","messageId":"AANLkTi=c51u=pQ3TLt3YE54mbwy8AqRb2rcsatEVo2U5@mail.gmail.com","threadId":"25179","inReplyTo":null,"subject":"more useful set-upstream","fromName":"Ramana Kumar","fromEmail":"ramana.kumar@gmail.com","sentAt":"2010-09-21T08:55:08Z","receivedAt":"2010-09-21T08:55:08Z","isPatch":false,"sender":{"key":"ramana.kumar@gmail.com","avatar":"https://gravatar.com/avatar/c1e354b4b3844c33709698d3c6491eb791f04384343001b78b4816b6ba3fa8a9?d=mp&s=160"},"body":"Is there a better way to achieve the functionality of this alias?\n\n  set-upstream = \"!sh -c 'current=$(git symbolic-ref HEAD); git branch\n\\\"$current\\\" --set-upstream \\\"$1\\\"/$(basename $current)' -\"\n\n(forgive me if stupid gmail word wrapped that line)\n\nThis allows me to write\n\n$ git set-upstream origin\n\ninstead of\n\n$ git branch <current branch> --set-upstream origin/<current branch>\n\nwhich is a pain to write for several reasons: I have to remember the current\nbranch name, that name might be long, and shell autocomplete doesn't know\nabout --set-upstream yet so won't complete the second occurrence.\n\nHaving a dedicated script (or git command) rather than an alias would allow\ngreater functionality like:\n - automatically pick the remote name if there's only one remote,\n - a flag to automatically set upstream on all branches (that having\n   matching remotes)\n\nI don't understand why all my branches haven't automatically had the right\nupstream set anyway - am I missing some configuration of pull and push?\n"},{"id":"151192","messageId":"vpqfwx3phou.fsf@bauges.imag.fr","threadId":"25179","inReplyTo":"AANLkTi=c51u=pQ3TLt3YE54mbwy8AqRb2rcsatEVo2U5@mail.gmail.com","subject":"Re: more useful set-upstream","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2010-09-21T09:30:25Z","receivedAt":"2010-09-21T09:30:25Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Ramana Kumar <ramana.kumar@gmail.com> writes:\n\n> I don't understand why all my branches haven't automatically had the right\n> upstream set anyway - am I missing some configuration of pull and\n> push?\n\nIf you keep it simple, they should:\n\n* git clone wherever => checks out the default branch, and sets the\n  upstream for it.\n\n* git checkout foo => if foo doesn't exist, and <remote>/foo exists,\n  foo is created and upstream is set to <remote>/foo (that's rather\n  recent)\n\nBut we could probably have a better way to set the upstream after the\nfact when the initialisation magic didn't do its job.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"}]}