{"thread":{"id":"40468","subject":"Convenient shortcut to push delete current branch?","startedAt":"2015-10-01T16:43:18Z","lastAt":"2015-10-02T13:33:50Z","messageCount":4,"participants":["Robert Dailey","Jacob Keller","Mike Rappazzo"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"270980","messageId":"CAHd499C3n8DGuhxwajQbFrH+Fr8zHRA7sVjhG3yfSD5kKPSZsA@mail.gmail.com","threadId":"40468","inReplyTo":null,"subject":"Convenient shortcut to push delete current branch?","fromName":"Robert Dailey","fromEmail":"rcdailey.lists@gmail.com","sentAt":"2015-10-01T16:43:18Z","receivedAt":"2015-10-01T16:43:18Z","isPatch":false,"sender":{"key":"rcdailey.lists@gmail.com","avatar":null},"body":"For convenient pushing of current branch, git supports this syntax:\n\n$ git push origin HEAD\n\nThis will push your current branch up. However, is there such a\nshortcut for *deleting* the branch? The only goal here is to avoid\nhaving to type the branch name in the push command. Normally I rely on\ntab completion but we have tons of branches, all which start with some\nprefix mixed with numbers, so it becomes cumbersome to rely on tab\ncompletion. Ideally I'd like to be able to do:\n\n$ git push --delete origin HEAD\n$ git push origin :HEAD\n\nIs there a syntax like this available?\n"},{"id":"270985","messageId":"CA+P7+xpWXoNiK67xCepoChr8rqX-Z5EcNb-Bs3xhC+Uot2ruYg@mail.gmail.com","threadId":"40468","inReplyTo":"CAHd499C3n8DGuhxwajQbFrH+Fr8zHRA7sVjhG3yfSD5kKPSZsA@mail.gmail.com","subject":"Re: Convenient shortcut to push delete current branch?","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2015-10-01T18:22:23Z","receivedAt":"2015-10-01T18:22:23Z","isPatch":false,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Thu, Oct 1, 2015 at 9:43 AM, Robert Dailey <rcdailey.lists@gmail.com> wrote:\n> For convenient pushing of current branch, git supports this syntax:\n>\n> $ git push origin HEAD\n>\n> This will push your current branch up. However, is there such a\n> shortcut for *deleting* the branch? The only goal here is to avoid\n> having to type the branch name in the push command. Normally I rely on\n> tab completion but we have tons of branches, all which start with some\n> prefix mixed with numbers, so it becomes cumbersome to rely on tab\n> completion. Ideally I'd like to be able to do:\n>\n> $ git push --delete origin HEAD\n> $ git push origin :HEAD\n>\n> Is there a syntax like this available?\n\nYou can do\n\ngit push origin:<branchname>\n\nbut I don't believe HEAD is supported. It might be valuable to extend\npush to have a --delete option which would maybe be useful for those\nwho didn't learn the full refspec syntax.\n\nI don't think git push origin :HEAD makes too much sense, since that's\non the remote side of a refspec, and you want it interpreted\nlocally... I suppose it makes sense somewhat, but other refspecs with\nHEAD on the remote side of the refspec don't really make sense, where\nas HEAD always makes sense on the local side of the refspec.\n\nRegards,\nJake\n"},{"id":"270986","messageId":"CAHd499C7r+Xd1+4Sn5WdXrEHv5yp0=jbnMUvLBHHJ-1s1sJ4gQ@mail.gmail.com","threadId":"40468","inReplyTo":"CA+P7+xpWXoNiK67xCepoChr8rqX-Z5EcNb-Bs3xhC+Uot2ruYg@mail.gmail.com","subject":"Re: Convenient shortcut to push delete current branch?","fromName":"Robert Dailey","fromEmail":"rcdailey.lists@gmail.com","sentAt":"2015-10-01T18:37:13Z","receivedAt":"2015-10-01T18:37:13Z","isPatch":false,"sender":{"key":"rcdailey.lists@gmail.com","avatar":null},"body":"On Thu, Oct 1, 2015 at 1:22 PM, Jacob Keller <jacob.keller@gmail.com> wrote:\n> On Thu, Oct 1, 2015 at 9:43 AM, Robert Dailey <rcdailey.lists@gmail.com> wrote:\n>> For convenient pushing of current branch, git supports this syntax:\n>>\n>> $ git push origin HEAD\n>>\n>> This will push your current branch up. However, is there such a\n>> shortcut for *deleting* the branch? The only goal here is to avoid\n>> having to type the branch name in the push command. Normally I rely on\n>> tab completion but we have tons of branches, all which start with some\n>> prefix mixed with numbers, so it becomes cumbersome to rely on tab\n>> completion. Ideally I'd like to be able to do:\n>>\n>> $ git push --delete origin HEAD\n>> $ git push origin :HEAD\n>>\n>> Is there a syntax like this available?\n>\n> You can do\n>\n> git push origin:<branchname>\n>\n> but I don't believe HEAD is supported. It might be valuable to extend\n> push to have a --delete option which would maybe be useful for those\n> who didn't learn the full refspec syntax.\n\nPush already has a --delete option.\n\n> I don't think git push origin :HEAD makes too much sense, since that's\n> on the remote side of a refspec, and you want it interpreted\n> locally... I suppose it makes sense somewhat, but other refspecs with\n> HEAD on the remote side of the refspec don't really make sense, where\n> as HEAD always makes sense on the local side of the refspec.\n\nHEAD makes sense on the remote side if you think of it like an alias:\n\nHEAD -> branch-name -> SHA1\n\nHEAD simply points to branch-name. It makes sense for git to assume\nthat we should never do anything with real HEAD ref on the remote\nside, and instead treat it as a substitution for the remote name. My\nassumption may not be correct, but at the very least it should be a\nniche case.\n"},{"id":"271008","messageId":"CANoM8SWkunV5Z1w9CsqfK2fGmrnghC2HdL5hZBDU7WkXz4aB6w@mail.gmail.com","threadId":"40468","inReplyTo":"CAHd499C7r+Xd1+4Sn5WdXrEHv5yp0=jbnMUvLBHHJ-1s1sJ4gQ@mail.gmail.com","subject":"Re: Convenient shortcut to push delete current branch?","fromName":"Mike Rappazzo","fromEmail":"rappazzo@gmail.com","sentAt":"2015-10-02T13:33:50Z","receivedAt":"2015-10-02T13:33:50Z","isPatch":false,"sender":{"key":"rappazzo@gmail.com","avatar":"https://avatars.githubusercontent.com/u/525287?v=4"},"body":"On Thu, Oct 1, 2015 at 2:37 PM, Robert Dailey <rcdailey.lists@gmail.com> wrote:\n> On Thu, Oct 1, 2015 at 1:22 PM, Jacob Keller <jacob.keller@gmail.com> wrote:\n>> On Thu, Oct 1, 2015 at 9:43 AM, Robert Dailey <rcdailey.lists@gmail.com> wrote:\n>>> For convenient pushing of current branch, git supports this syntax:\n>>>\n>>> $ git push origin HEAD\n>>>\n>>> This will push your current branch up. However, is there such a\n>>> shortcut for *deleting* the branch? The only goal here is to avoid\n>>> having to type the branch name in the push command. Normally I rely on\n>>> tab completion but we have tons of branches, all which start with some\n>>> prefix mixed with numbers, so it becomes cumbersome to rely on tab\n>>> completion. Ideally I'd like to be able to do:\n>>>\n>>> $ git push --delete origin HEAD\n>>> $ git push origin :HEAD\n>>>\n>>> Is there a syntax like this available?\n>>\n>> You can do\n>>\n>> git push origin:<branchname>\n>>\n>> but I don't believe HEAD is supported. It might be valuable to extend\n>> push to have a --delete option which would maybe be useful for those\n>> who didn't learn the full refspec syntax.\n>\n> Push already has a --delete option.\n>\n\nI could see adding an option for --delete-upstream that would use the\nupstream remote and ref of the current branch (if they exist).\nExternal to git you could script this from the config (completely\nuntested):\n\n    if branch=$(git symbolic-ref --short HEAD); then\n        if remote=$(git config branch.$branch.remote); then\n            if remote_ref=$(git config branch.$branch.merge); then\n                git push $remote --delete $remote_ref\n            fi\n        fi\n    fi\n\n>> I don't think git push origin :HEAD makes too much sense, since that's\n>> on the remote side of a refspec, and you want it interpreted\n>> locally... I suppose it makes sense somewhat, but other refspecs with\n>> HEAD on the remote side of the refspec don't really make sense, where\n>> as HEAD always makes sense on the local side of the refspec.\n>\n> HEAD makes sense on the remote side if you think of it like an alias:\n>\n> HEAD -> branch-name -> SHA1\n>\n> HEAD simply points to branch-name. It makes sense for git to assume\n> that we should never do anything with real HEAD ref on the remote\n> side, and instead treat it as a substitution for the remote name. My\n> assumption may not be correct, but at the very least it should be a\n> niche case.\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"}]}