{"thread":{"id":"31053","subject":"pushing branches","startedAt":"2012-07-20T15:26:09Z","lastAt":"2012-07-22T18:40:54Z","messageCount":13,"participants":["Thiago Farina","Junio C Hamano","PJ Weisberg","Konstantin Khomoutov","Matthieu Moy"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"195366","messageId":"CACnwZYdqP_ptj0++dj5NkCoKWKHiLEj+c0t7zrmNidkHsyzMgw@mail.gmail.com","threadId":"31053","inReplyTo":null,"subject":"pushing branches","fromName":"Thiago Farina","fromEmail":"tfransosi@gmail.com","sentAt":"2012-07-20T15:26:09Z","receivedAt":"2012-07-20T15:26:09Z","isPatch":false,"sender":{"key":"tfransosi@gmail.com","avatar":"https://avatars.githubusercontent.com/u/970071?v=4"},"body":"Hi,\n\nHow can I push a working branch to github inside it?\n\nE.g:\n\n# On master:\n$ git checkout -b feature-work\n\n# On feature-work\n# vi, hack, commit, ready to push\n$ git push origin master # here I expected it would working pushing my\ncommits to a feature-work branch in github. Or if I omit master it\ngives me a [rejected] error.\nEverything up-to-date.\n\n$ git checkout master\n$ git push origin feature-work # Now the branch is pushed.\n\nThanks,\n"},{"id":"195371","messageId":"7vhat2toz8.fsf@alter.siamese.dyndns.org","threadId":"31053","inReplyTo":"CACnwZYdqP_ptj0++dj5NkCoKWKHiLEj+c0t7zrmNidkHsyzMgw@mail.gmail.com","subject":"Re: pushing branches","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-07-20T15:46:19Z","receivedAt":"2012-07-20T15:46:19Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thiago Farina <tfransosi@gmail.com> writes:\n\n> How can I push a working branch to github inside it?\n>\n> E.g:\n>\n> # On master:\n> $ git checkout -b feature-work\n>\n> # On feature-work\n> # vi, hack, commit, ready to push\n> $ git push origin master # here I expected it would working pushing my\n\n\"git push origin master\" is a short-hand for \"git push origin\nrefs/heads/master:refs/heads/master\" to update their master branch\nwith what you have in your master branch. \n\nSee output from\n\n    $ git push --help\n\nfor details.\n\nI think you are trying to update, while on your feature-work branch,\ntheir master with your feature-work branch (or more generally, the\ncurrent HEAD), so\n\n    $ git push origin HEAD:master\n\nis perhaps what you are looking for?    \n"},{"id":"195372","messageId":"CAJsNXTk33zN_cWcyyvPz4-FKzGZDB0CBp=YtSDVNix-ynP4-7g@mail.gmail.com","threadId":"31053","inReplyTo":"CACnwZYdqP_ptj0++dj5NkCoKWKHiLEj+c0t7zrmNidkHsyzMgw@mail.gmail.com","subject":"Re: pushing branches","fromName":"PJ Weisberg","fromEmail":"pj@irregularexpressions.net","sentAt":"2012-07-20T15:46:39Z","receivedAt":"2012-07-20T15:46:39Z","isPatch":false,"sender":{"key":"pj@irregularexpressions.net","avatar":"https://gravatar.com/avatar/aa2c1edcc61b536cc5c9f37fbce084e655446e2309f9818d43f13d47304a602b?d=mp&s=160"},"body":"On Fri, Jul 20, 2012 at 8:26 AM, Thiago Farina <tfransosi@gmail.com> wrote:\n> Hi,\n>\n> How can I push a working branch to github inside it?\n>\n> E.g:\n>\n> # On master:\n> $ git checkout -b feature-work\n>\n> # On feature-work\n> # vi, hack, commit, ready to push\n> $ git push origin master # here I expected it would working pushing my\n> commits to a feature-work branch in github. Or if I omit master it\n> gives me a [rejected] error.\n> Everything up-to-date.\n>\n> $ git checkout master\n> $ git push origin feature-work # Now the branch is pushed.\n\n???\n\nI must be missing something.  It looks like the reason it didn't push\nfeature-work the first time is because you told it to push master\ninstead.\n\n-PJ\n\nGehm's Corollary to Clark's Law: Any technology distinguishable from\nmagic is insufficiently advanced.\n"},{"id":"195374","messageId":"20120720194905.9929a30ee42fd73cf62e7992@domain007.com","threadId":"31053","inReplyTo":"CACnwZYdqP_ptj0++dj5NkCoKWKHiLEj+c0t7zrmNidkHsyzMgw@mail.gmail.com","subject":"Re: pushing branches","fromName":"Konstantin Khomoutov","fromEmail":"flatworm@users.sourceforge.net","sentAt":"2012-07-20T15:49:05Z","receivedAt":"2012-07-20T15:49:05Z","isPatch":false,"sender":{"key":"flatworm@users.sourceforge.net","avatar":null},"body":"On Fri, 20 Jul 2012 12:26:09 -0300\nThiago Farina <tfransosi@gmail.com> wrote:\n\n> How can I push a working branch to github inside it?\n> \n> E.g:\n> \n> # On master:\n> $ git checkout -b feature-work\n> \n> # On feature-work\n> # vi, hack, commit, ready to push\n> $ git push origin master # here I expected it would working pushing my\n> commits to a feature-work branch in github. Or if I omit master it\n> gives me a [rejected] error.\n$ git push origin master\nmeans \"update the branch 'master' in the remote repository with the\ncontents of the branch 'master' in the local repository\".\nRead the \"git push\" manual.\n\n> $ git checkout master\n> $ git push origin feature-work # Now the branch is pushed.\nSure, but it has nothing to do with the previous checkout command: you\njust told Git to push the contents of your local branch \"feature-work\"\nto a remote branch \"feature-work\" which presumably does not exist and\ngets created as a result of your push.\n\nIf you want to update the remote \"master\" branch with the contents of\nyour local \"feature-work\" branch, do\n$ git push origin feature-work:master\n\nAs stated below, you should really read the git push manual and reading\nthrough the appropriate sections of the http://git-scm.com/book is also\nhighly advised.\n\nAlso consider reading about the \"push.default\" configuration variable\nin the git config manual--this might save you from scratching your head\nwhen you try to do simple `git push origin` without specifying any\nbranches: here again your expectation might differ from the Git\ndefaults.\n"},{"id":"195375","messageId":"CACnwZYchBpSsvfY_-cu33dmPateNPgYaPr822Ri=Xn6=V0OOnA@mail.gmail.com","threadId":"31053","inReplyTo":"7vhat2toz8.fsf@alter.siamese.dyndns.org","subject":"Re: pushing branches","fromName":"Thiago Farina","fromEmail":"tfransosi@gmail.com","sentAt":"2012-07-20T15:49:32Z","receivedAt":"2012-07-20T15:49:32Z","isPatch":false,"sender":{"key":"tfransosi@gmail.com","avatar":"https://avatars.githubusercontent.com/u/970071?v=4"},"body":"On Fri, Jul 20, 2012 at 12:46 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Thiago Farina <tfransosi@gmail.com> writes:\n>\n>> How can I push a working branch to github inside it?\n>>\n>> E.g:\n>>\n>> # On master:\n>> $ git checkout -b feature-work\n>>\n>> # On feature-work\n>> # vi, hack, commit, ready to push\n>> $ git push origin master # here I expected it would working pushing my\n>\n> \"git push origin master\" is a short-hand for \"git push origin\n> refs/heads/master:refs/heads/master\" to update their master branch\n> with what you have in your master branch.\n>\n> See output from\n>\n>     $ git push --help\n>\n> for details.\n>\n> I think you are trying to update, while on your feature-work branch,\n> their master with your feature-work branch (or more generally, the\n> current HEAD), so\n>\n>     $ git push origin HEAD:master\n>\n> is perhaps what you are looking for?\n\nWhat I'm looking for is to upload/create the remote branch in github\nfrom inside my local branch, without having to checkout master in\norder to do so.\n"},{"id":"195377","messageId":"vpqzk6uo2dc.fsf@bauges.imag.fr","threadId":"31053","inReplyTo":"CACnwZYdqP_ptj0++dj5NkCoKWKHiLEj+c0t7zrmNidkHsyzMgw@mail.gmail.com","subject":"Re: pushing branches","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2012-07-20T15:53:35Z","receivedAt":"2012-07-20T15:53:35Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Thiago Farina <tfransosi@gmail.com> writes:\n\n> $ git push origin master # here I expected it would working pushing my\n> commits to a feature-work branch in github. Or if I omit master it\n> gives me a [rejected] error.\n> Everything up-to-date.\n\nIf your workflow is to push one branch at a time, and you have the same\nnaming locally and remotely (i.e. your local branch feature-work should\nbe pushed as feature-work on github), then you probably want to set the\nvariable 'push.default' to either 'current', 'upstream' or 'simple' if\nyou use the last version of Git. Read about it there:\n\n  http://git-scm.com/docs/git-config\n\n(search push.default)\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"195384","messageId":"CAJsNXTkH6wRgH9g4BCZVxKz9ntf0P_Y81kc+bAhcchkQM3+3Bw@mail.gmail.com","threadId":"31053","inReplyTo":"CACnwZYchBpSsvfY_-cu33dmPateNPgYaPr822Ri=Xn6=V0OOnA@mail.gmail.com","subject":"Re: pushing branches","fromName":"PJ Weisberg","fromEmail":"pj@irregularexpressions.net","sentAt":"2012-07-20T19:19:57Z","receivedAt":"2012-07-20T19:19:57Z","isPatch":false,"sender":{"key":"pj@irregularexpressions.net","avatar":"https://gravatar.com/avatar/aa2c1edcc61b536cc5c9f37fbce084e655446e2309f9818d43f13d47304a602b?d=mp&s=160"},"body":"On Fri, Jul 20, 2012 at 8:49 AM, Thiago Farina <tfransosi@gmail.com> wrote:\n\n> What I'm looking for is to upload/create the remote branch in github\n> from inside my local branch, without having to checkout master in\n> order to do so.\n\nIn that case, do exactly what you did, except don't checkout master.\n\n-PJ\n\nGehm's Corollary to Clark's Law: Any technology distinguishable from\nmagic is insufficiently advanced.\n"},{"id":"195393","messageId":"CACnwZYe03VzR0=m6oCo8X6y=iiLkZXi+xQpvW9goya0roU+PFQ@mail.gmail.com","threadId":"31053","inReplyTo":"CAJsNXTkH6wRgH9g4BCZVxKz9ntf0P_Y81kc+bAhcchkQM3+3Bw@mail.gmail.com","subject":"Re: pushing branches","fromName":"Thiago Farina","fromEmail":"tfransosi@gmail.com","sentAt":"2012-07-21T01:40:20Z","receivedAt":"2012-07-21T01:40:20Z","isPatch":false,"sender":{"key":"tfransosi@gmail.com","avatar":"https://avatars.githubusercontent.com/u/970071?v=4"},"body":"On Fri, Jul 20, 2012 at 4:19 PM, PJ Weisberg\n<pj@irregularexpressions.net> wrote:\n> On Fri, Jul 20, 2012 at 8:49 AM, Thiago Farina <tfransosi@gmail.com> wrote:\n>\n>> What I'm looking for is to upload/create the remote branch in github\n>> from inside my local branch, without having to checkout master in\n>> order to do so.\n>\n> In that case, do exactly what you did, except don't checkout master.\n>\nWhy you suggest that? If I demonstrated that origin master or just\norigin in the current branch doesn't do what I want, i.e, push it to\ngithub.\n"},{"id":"195394","messageId":"CAJsNXT=-Ap0zJqK2F_3uJ7secmq7uvnSc218x+NoYdO5pLJAMg@mail.gmail.com","threadId":"31053","inReplyTo":"CACnwZYe03VzR0=m6oCo8X6y=iiLkZXi+xQpvW9goya0roU+PFQ@mail.gmail.com","subject":"Re: pushing branches","fromName":"PJ Weisberg","fromEmail":"pj@irregularexpressions.net","sentAt":"2012-07-21T01:58:40Z","receivedAt":"2012-07-21T01:58:40Z","isPatch":false,"sender":{"key":"pj@irregularexpressions.net","avatar":"https://gravatar.com/avatar/aa2c1edcc61b536cc5c9f37fbce084e655446e2309f9818d43f13d47304a602b?d=mp&s=160"},"body":"On Fri, Jul 20, 2012 at 6:40 PM, Thiago Farina <tfransosi@gmail.com> wrote:\n> On Fri, Jul 20, 2012 at 4:19 PM, PJ Weisberg\n> <pj@irregularexpressions.net> wrote:\n>> On Fri, Jul 20, 2012 at 8:49 AM, Thiago Farina <tfransosi@gmail.com> wrote:\n>>\n>>> What I'm looking for is to upload/create the remote branch in github\n>>> from inside my local branch, without having to checkout master in\n>>> order to do so.\n>>\n>> In that case, do exactly what you did, except don't checkout master.\n>>\n> Why you suggest that? If I demonstrated that origin master or just\n> origin in the current branch doesn't do what I want, i.e, push it to\n> github.\n\nIn your original email, you had one command that did what you wanted\nand one that didn't.\n\n$ git push origin master\n$ git push origin feature-work\n\nCan you spot the difference between them?\n\nLike Konstantin said, you can look into the different options for\npush.default, but don't expect Git to push one branch when you told it\nto push another.\n\n-PJ\n\nGehm's Corollary to Clark's Law: Any technology distinguishable from\nmagic is insufficiently advanced.\n"},{"id":"195395","messageId":"CACnwZYdUzk74znPs4F+xz3haA3QhA9-DbR3mWWEVMfnztp-oCA@mail.gmail.com","threadId":"31053","inReplyTo":"CAJsNXT=-Ap0zJqK2F_3uJ7secmq7uvnSc218x+NoYdO5pLJAMg@mail.gmail.com","subject":"Re: pushing branches","fromName":"Thiago Farina","fromEmail":"tfransosi@gmail.com","sentAt":"2012-07-21T02:10:56Z","receivedAt":"2012-07-21T02:10:56Z","isPatch":false,"sender":{"key":"tfransosi@gmail.com","avatar":"https://avatars.githubusercontent.com/u/970071?v=4"},"body":"On Fri, Jul 20, 2012 at 10:58 PM, PJ Weisberg\n<pj@irregularexpressions.net> wrote:\n> In your original email, you had one command that did what you wanted\n> and one that didn't.\n>\n> $ git push origin master\n> $ git push origin feature-work\n>\n> Can you spot the difference between them?\n>\nDo'h, now I can see the idiocy that I was doing.\n\nIf I'm understanding this better,\n$ git push origin master\ntells git to push to remote origin, the contents of my master branch.\n\nAnd then,\n\n$ git push origin feature-work\ntells git to push to remote origin to push the contents of feature-work branch.\n\nHence does not make sense to ask git to do \"push origin master\" while\ninside feature-work branch.\n\n> Like Konstantin said, you can look into the different options for\n> push.default, but don't expect Git to push one branch when you told it\n> to push another.\n>\n> -PJ\n>\n> Gehm's Corollary to Clark's Law: Any technology distinguishable from\n> magic is insufficiently advanced.\n"},{"id":"195424","messageId":"7v7gtwucx7.fsf@alter.siamese.dyndns.org","threadId":"31053","inReplyTo":"CACnwZYdUzk74znPs4F+xz3haA3QhA9-DbR3mWWEVMfnztp-oCA@mail.gmail.com","subject":"Re: pushing branches","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-07-21T19:33:40Z","receivedAt":"2012-07-21T19:33:40Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thiago Farina <tfransosi@gmail.com> writes:\n\n> Do'h, now I can see the idiocy that I was doing.\n>\n> If I'm understanding this better,\n> $ git push origin master\n> tells git to push to remote origin, the contents of my master branch.\n\nYes, add \"to the 'master' at the 'origin'\" at the end of the\nsentence and you are perfect.\n\n> And then,\n>\n> $ git push origin feature-work\n> tells git to push to remote origin to push the contents of feature-work branch.\n\nYes.\n\n> Hence does not make sense to ask git to do \"push origin master\" while\n> inside feature-work branch.\n\nNo.  As long as you know your master is ready and suitable to be\npublished when you ask \"push\", the command perfectly makes sense; it\ndoes not matter on what branch you are on.\n\nYou may say\n\n\t$ git checkout master\n        ... work work work ...\n        $ make test\n        ... ahh, perfection! ...\n        $ git checkout -b feature\n        ... let's build a bit more ..\n        ... while I am having fun, let's not forget to push the\n        ... part that is already solid out\n        $ git push origin master\n\nand that is perfectly fine without \"git checkout master\" before\npushing (and \"git checkout feature\" after to come back to what you\nwere doing).\n"},{"id":"195435","messageId":"CACnwZYcP7Ke-zyMLT8JBGt_BHS22G4cN6GYe+yauxXF6cVLZ1g@mail.gmail.com","threadId":"31053","inReplyTo":"7v7gtwucx7.fsf@alter.siamese.dyndns.org","subject":"Re: pushing branches","fromName":"Thiago Farina","fromEmail":"tfransosi@gmail.com","sentAt":"2012-07-22T02:54:21Z","receivedAt":"2012-07-22T02:54:21Z","isPatch":false,"sender":{"key":"tfransosi@gmail.com","avatar":"https://avatars.githubusercontent.com/u/970071?v=4"},"body":"On Sat, Jul 21, 2012 at 4:33 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Yes.\n>\n>> Hence does not make sense to ask git to do \"push origin master\" while\n>> inside feature-work branch.\n>\n> No.  As long as you know your master is ready and suitable to be\n> published when you ask \"push\", the command perfectly makes sense; it\n> does not matter on what branch you are on.\n>\n> You may say\n>\n>         $ git checkout master\n>         ... work work work ...\n>         $ make test\n>         ... ahh, perfection! ...\n>         $ git checkout -b feature\n>         ... let's build a bit more ..\n>         ... while I am having fun, let's not forget to push the\n>         ... part that is already solid out\n>         $ git push origin master\n>\n> and that is perfectly fine without \"git checkout master\" before\n> pushing (and \"git checkout feature\" after to come back to what you\n> were doing).\nIn my case it wouldn't because I do not modify my master branch, I\njust fetch upstream, merge upstream/master into my local master branch\nand switch to feature-work, then git push origin master will always\ngive me \"Everything up-to-date\" I suppose (that is what always happen\nin my case/workflow).\n\nAnd just learned, the answer to my question is, while in feature-work\nbranch, 'git push origin feature-work'. Which does what I wanted.\n"},{"id":"195448","messageId":"7vobn7skp5.fsf@alter.siamese.dyndns.org","threadId":"31053","inReplyTo":"CACnwZYcP7Ke-zyMLT8JBGt_BHS22G4cN6GYe+yauxXF6cVLZ1g@mail.gmail.com","subject":"Re: pushing branches","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-07-22T18:40:54Z","receivedAt":"2012-07-22T18:40:54Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thiago Farina <tfransosi@gmail.com> writes:\n\n> On Sat, Jul 21, 2012 at 4:33 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>> Yes.\n>>\n>>> Hence does not make sense to ask git to do \"push origin master\" while\n>>> inside feature-work branch.\n>> ...\n>> No.  As long as you know your master is ready and suitable to be\n>> published when you ask \"push\", the command perfectly makes sense; it\n>> does not matter on what branch you are on.\n>> ...\n> In my case it wouldn't because I do not modify my master branch, I\n> just fetch upstream, merge upstream/master into my local master branch\n> and switch to feature-work, then git push origin master will always\n> give me \"Everything up-to-date\" I suppose (that is what always happen\n> in my case/workflow).\n\nIt would not make _any_ sense to ask \"git push origin master\"\nregardless of which branch you are on if that is the case, as you\nare not modifying, then.\n"}]}