{"thread":{"id":"8964","subject":"pushing changes to a remote branch","startedAt":"2007-07-10T14:36:14Z","lastAt":"2007-07-14T08:38:43Z","messageCount":10,"participants":["martin f krafft","Jeff King","Brian Gernhardt","Sean Kelley","Jan Hudec","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"46953","messageId":"20070710143614.GA29681@piper.oerlikon.madduck.net","threadId":"8964","inReplyTo":null,"subject":"pushing changes to a remote branch","fromName":"martin f krafft","fromEmail":"madduck@madduck.net","sentAt":"2007-07-10T14:36:14Z","receivedAt":"2007-07-10T14:36:14Z","isPatch":false,"sender":{"key":"madduck@madduck.net","avatar":null},"body":"Hi list,\n\nI am using git-remote to clone a remote repository and track only\na select number of branches:\n\n  git remote add -f -t vim -t ssh origin git://git.server.org/path/to/repo.git\n  git branch -r\n    origin/ssh\n    origin/vim\n  git merge ...\n\nI now merge these into the local repo and decide that I need to make\na change to origin/vim. So I figure that it's probably easiest if\nI just checkout the remote branch, make the change, commit it, push\nit, return to the master branch, git-remote update and merge, but:\n\n  git checkout origin/vim\n    Note: moving to \"origin/vim\" which isn't a local branch\n  echo change > newfile; git add newfile\n  git commit -m'make change'\n    Created commit 64b8b2e: make change\n     1 files changed, 1 insertions(+), 0 deletions(-)\n      create mode 100644 newfile\n  \nIf I now checkout master and then return to origin/vim, the commit\nis gone.\n\nIf I repeat all this and, instead of returning to master, I push the\ncommit to origin, git suggests success (the push looks normal).\nHowever, I then cannot find the commit anymore. It's not available\nlocally, nor in origin/vim, nor in the local master branch or in\norigin/master.\n\nThis is curious and I'd love to find out what's going on.\n\nMuch more, however, I am interested how I am supposed to push\ncommits back to select remote branches.\n\nUsing\n\n  git push git://git.server.org/path/to/repo.git \\\n    7fbb0655:refs/heads/vim\n\ndoes push commit 7fbb0655 to the vim branch in the remote\nrepository, but I should be able to do this using origin/vim, no?\nHow?\n\n-- \nmartin;              (greetings from the heart of the sun.)\n  \\____ echo mailto: !#^.\"<*>\"|tr \"<*> mailto:\" net@madduck\n \nspamtraps: madduck.bogus@madduck.net\n \n\"the worst part of being old is remembering when you was young.\"\n                                -- alvin straight (the straight story)\n"},{"id":"46970","messageId":"20070710173401.GB5032@sigill.intra.peff.net","threadId":"8964","inReplyTo":"20070710143614.GA29681@piper.oerlikon.madduck.net","subject":"Re: pushing changes to a remote branch","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-07-10T17:34:01Z","receivedAt":"2007-07-10T17:34:01Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jul 10, 2007 at 04:36:14PM +0200, martin f krafft wrote:\n\n>   git checkout origin/vim\n>     Note: moving to \"origin/vim\" which isn't a local branch\n>   echo change > newfile; git add newfile\n>   git commit -m'make change'\n>     Created commit 64b8b2e: make change\n>      1 files changed, 1 insertions(+), 0 deletions(-)\n>       create mode 100644 newfile\n>   \n> If I now checkout master and then return to origin/vim, the commit\n> is gone.\n\nThat's because 'origin/vim' is a tracking branch for the remote; it's\nwhere you store the information \"here's what the remote 'origin' thinks\nis in the branch 'vim'.\" That's why you get the \"note\" warning above.\n\nIf you want to make changes, you should make a local branch starting\nfrom that point:\n\n  git-checkout -b vim origin/vim\n  # hack hack hack\n  git-commit -m changes\n\n> Much more, however, I am interested how I am supposed to push\n> commits back to select remote branches.\n\nNow when you issue a git-push, you will push _your_ 'vim' branch to the\nremote's 'vim' branch. Before, you didn't _have_ a vim branch, so\nnothing was pushed.\n\nSo the key thing you are missing in all of this is that you shouldn't be\ndoing _anything_ with branches in origin/* (which are, of course,\nactually refs/remotes/origin/*) except for read-only operations (like\ndiffing against them, merging with them, etc). They are purely for\ntracking the remote's branches.\n\n-Peff\n"},{"id":"46975","messageId":"844FC382-DFB3-4762-93C2-6512612136AC@silverinsanity.com","threadId":"8964","inReplyTo":"20070710173401.GB5032@sigill.intra.peff.net","subject":"Re: pushing changes to a remote branch","fromName":"Brian Gernhardt","fromEmail":"benji@silverinsanity.com","sentAt":"2007-07-10T18:10:01Z","receivedAt":"2007-07-10T18:10:01Z","isPatch":false,"sender":{"key":"benji@silverinsanity.com","avatar":"https://gravatar.com/avatar/e06c101dbc25c68114d859b4a9ec7cf8a2c52fd2b0270ef0eac0e2e63ff22311?d=mp&s=160"},"body":"\nOn Jul 10, 2007, at 1:34 PM, Jeff King wrote:\n\n> On Tue, Jul 10, 2007 at 04:36:14PM +0200, martin f krafft wrote:\n>\n>>   git checkout origin/vim\n>>     Note: moving to \"origin/vim\" which isn't a local branch\n>>   echo change > newfile; git add newfile\n>>   git commit -m'make change'\n>>     Created commit 64b8b2e: make change\n>>      1 files changed, 1 insertions(+), 0 deletions(-)\n>>       create mode 100644 newfile\n>>\n>> If I now checkout master and then return to origin/vim, the commit\n>> is gone.\n>\n> That's because 'origin/vim' is a tracking branch for the remote; it's\n> where you store the information \"here's what the remote 'origin'  \n> thinks\n> is in the branch 'vim'.\" That's why you get the \"note\" warning above.\n>\n> If you want to make changes, you should make a local branch starting\n> from that point:\n>\n>   git-checkout -b vim origin/vim\n>   # hack hack hack\n>   git-commit -m changes\n\nIndeed, in master, git outputs a hint to that when you checkout the  \nremote branch.\n\n   $ git checkout origin/master\n   Note: moving to \"origin/master\" which isn't a local branch\n   If you want to create a new branch from this checkout, you may do so\n   (now or later) by using -b with the checkout command again. Example:\n     git checkout -b <new_branch_name>\n   HEAD is now at f4855d4... 1\n\nPerhaps git-commit should also also output a warning?  \"Commit made  \non detached HEAD.  Use \"git branch <new_branch_name>\" to save your  \ncommit\"?  That's bad wording, but the idea is there.\n\n~~ Brian\n"},{"id":"46988","messageId":"20070710220458.GA2295@coredump.intra.peff.net","threadId":"8964","inReplyTo":"844FC382-DFB3-4762-93C2-6512612136AC@silverinsanity.com","subject":"Re: pushing changes to a remote branch","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-07-10T22:04:58Z","receivedAt":"2007-07-10T22:04:58Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jul 10, 2007 at 02:10:01PM -0400, Brian Gernhardt wrote:\n\n> Perhaps git-commit should also also output a warning?  \"Commit made on \n> detached HEAD.  Use \"git branch <new_branch_name>\" to save your commit\"?  \n> That's bad wording, but the idea is there.\n\nThere was much discussion in this area, and the conclusion (and current\nbehavior) is:\n\n1. Notify about the state change to detached HEAD, since some commands\n   will be subtly different.\n2. Don't warn about commiting on detached HEAD, since there is nothing\n   technically wrong with it.\n3. When moving away from detached HEAD, print the previous HEAD\n   position, so the user knows what might have been lost.\n\nSee this message (and a bunch of surrounding messages):\n\n  http://article.gmane.org/gmane.comp.version-control.git/38254\n\nIt would be nice if we could allow (3) only when commits weren't being\nlost, but that would require doing a reachability analysis from all\nrefs, which is expensive. The reflog for HEAD makes those commits\nrecoverable, as well.\n\nPersonally, I think (2) (commits on detached HEAD) should simply be\ndisallowed, since it is simple enough to 'git checkout -b newbranch' as\nan override (and I have not personally found a need for commits on\ndetached HEAD, anyway), and it saves the exact newbie error that Martin\nran into. But others obviously disagree.\n\n-Peff\n"},{"id":"47004","messageId":"a2e879e50707102044l864b9dcre5b6fa5893ff4803@mail.gmail.com","threadId":"8964","inReplyTo":"844FC382-DFB3-4762-93C2-6512612136AC@silverinsanity.com","subject":"Re: pushing changes to a remote branch","fromName":"Sean Kelley","fromEmail":"svk.sweng@gmail.com","sentAt":"2007-07-11T03:44:58Z","receivedAt":"2007-07-11T03:44:58Z","isPatch":false,"sender":{"key":"svk.sweng@gmail.com","avatar":null},"body":"Hi,\n\nOn 7/10/07, Brian Gernhardt <benji@silverinsanity.com> wrote:\n>\n> On Jul 10, 2007, at 1:34 PM, Jeff King wrote:\n>\n> > On Tue, Jul 10, 2007 at 04:36:14PM +0200, martin f krafft wrote:\n> >\n> >>   git checkout origin/vim\n> >>     Note: moving to \"origin/vim\" which isn't a local branch\n> >>   echo change > newfile; git add newfile\n> >>   git commit -m'make change'\n> >>     Created commit 64b8b2e: make change\n> >>      1 files changed, 1 insertions(+), 0 deletions(-)\n> >>       create mode 100644 newfile\n> >>\n> >> If I now checkout master and then return to origin/vim, the commit\n> >> is gone.\n> >\n> > That's because 'origin/vim' is a tracking branch for the remote; it's\n> > where you store the information \"here's what the remote 'origin'\n> > thinks\n> > is in the branch 'vim'.\" That's why you get the \"note\" warning above.\n> >\n> > If you want to make changes, you should make a local branch starting\n> > from that point:\n> >\n> >   git-checkout -b vim origin/vim\n> >   # hack hack hack\n> >   git-commit -m changes\n>\n> Indeed, in master, git outputs a hint to that when you checkout the\n> remote branch.\n>\n>    $ git checkout origin/master\n>    Note: moving to \"origin/master\" which isn't a local branch\n>    If you want to create a new branch from this checkout, you may do so\n>    (now or later) by using -b with the checkout command again. Example:\n>      git checkout -b <new_branch_name>\n>    HEAD is now at f4855d4... 1\n>\n> Perhaps git-commit should also also output a warning?  \"Commit made\n> on detached HEAD.  Use \"git branch <new_branch_name>\" to save your\n> commit\"?  That's bad wording, but the idea is there.\n\n\nIf you then do a push from that new_branch_name will it create a new\nbranch on the remote?  I am struggling with just being able to add a\nremote.  Create a local branch that maps to the remote.  Then\ncommitting and pushing changes to the remote - all without creating a\nnew branch on the remote.\n\nSean\n\n>\n> ~~ Brian\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>\n"},{"id":"47064","messageId":"20070711192959.GB3069@efreet.light.src","threadId":"8964","inReplyTo":"20070710143614.GA29681@piper.oerlikon.madduck.net","subject":"Re: pushing changes to a remote branch","fromName":"Jan Hudec","fromEmail":"bulb@ucw.cz","sentAt":"2007-07-11T19:29:59Z","receivedAt":"2007-07-11T19:29:59Z","isPatch":false,"sender":{"key":"bulb@ucw.cz","avatar":null},"body":"On Tue, Jul 10, 2007 at 16:36:14 +0200, martin f krafft wrote:\n>   git checkout origin/vim\n>     Note: moving to \"origin/vim\" which isn't a local branch\n\nThere is more to that message, no? However, it only says \"Head is now at\n<commit-id>\", which does not really indicate, that the HEAD has been\n\"detached\". This means that it now contains a commit-id rather than name of\nsome branch.\n\nGit detaches head whenever you check out, without -b option, anything other\nthan branch (without it's refs/heads prefix). If you than check out a branch,\nyou can't see the commit on any branch anymore. However, you can still access\nit in reflog, ie. via expressions like HEAD@{1} or HEAD@{1 hour ago}.\n\nYou should also be able to:\n\n git push origin HEAD:vim\n\nafter the commit, and even (I didn't try it, but documentation seems to claim\nit should work):\n\n git push origin HEAD@{1}:vim\n\nif you already changed HEAD more.\n\nYou can see this \"metahistory\" of HEAD via:\n\n git reflog\n\nwhich is shorthand for git reflog show HEAD\n\n-- \n\t\t\t\t\t\t Jan 'Bulb' Hudec <bulb@ucw.cz>\n"},{"id":"47065","messageId":"20070711193152.GC3069@efreet.light.src","threadId":"8964","inReplyTo":"844FC382-DFB3-4762-93C2-6512612136AC@silverinsanity.com","subject":"Re: pushing changes to a remote branch","fromName":"Jan Hudec","fromEmail":"bulb@ucw.cz","sentAt":"2007-07-11T19:31:52Z","receivedAt":"2007-07-11T19:31:52Z","isPatch":false,"sender":{"key":"bulb@ucw.cz","avatar":null},"body":"On Tue, Jul 10, 2007 at 14:10:01 -0400, Brian Gernhardt wrote:\n> Indeed, in master, git outputs a hint to that when you checkout the remote \n> branch.\n>\n>   $ git checkout origin/master\n>   Note: moving to \"origin/master\" which isn't a local branch\n>   If you want to create a new branch from this checkout, you may do so\n>   (now or later) by using -b with the checkout command again. Example:\n>     git checkout -b <new_branch_name>\n>   HEAD is now at f4855d4... 1\n\nThe problem of this warning is, that it does not actually say anything about\ndetached and that potential commit won't update the ref being checked out.\n\n> Perhaps git-commit should also also output a warning?  \"Commit made on \n> detached HEAD.  Use \"git branch <new_branch_name>\" to save your commit\"?  \n> That's bad wording, but the idea is there.\n\n-- \n\t\t\t\t\t\t Jan 'Bulb' Hudec <bulb@ucw.cz>\n"},{"id":"47066","messageId":"20070711193444.GD3069@efreet.light.src","threadId":"8964","inReplyTo":"a2e879e50707102044l864b9dcre5b6fa5893ff4803@mail.gmail.com","subject":"Re: pushing changes to a remote branch","fromName":"Jan Hudec","fromEmail":"bulb@ucw.cz","sentAt":"2007-07-11T19:34:44Z","receivedAt":"2007-07-11T19:34:44Z","isPatch":false,"sender":{"key":"bulb@ucw.cz","avatar":null},"body":"On Tue, Jul 10, 2007 at 22:44:58 -0500, Sean Kelley wrote:\n> If you then do a push from that new_branch_name will it create a new\n> branch on the remote?  I am struggling with just being able to add a\n> remote.  Create a local branch that maps to the remote.  Then\n> committing and pushing changes to the remote - all without creating a\n> new branch on the remote.\n\ngit push takes a refspec, which is local-branch:remote-branch. So you can\npush from local branch of any name to remote branch of any other name. You\ncan also define the relationships in the config, but you'll have to look up\nwhat exactly you should specify in the manuals (of git-push and git-config).\n\n-- \n\t\t\t\t\t\t Jan 'Bulb' Hudec <bulb@ucw.cz>\n"},{"id":"47076","messageId":"7v1wfe4op5.fsf@assigned-by-dhcp.cox.net","threadId":"8964","inReplyTo":"20070711193152.GC3069@efreet.light.src","subject":"Re: pushing changes to a remote branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-07-11T21:26:14Z","receivedAt":"2007-07-11T21:26:14Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jan Hudec <bulb@ucw.cz> writes:\n\n>>   $ git checkout origin/master\n>>   Note: moving to \"origin/master\" which isn't a local branch\n>>   If you want to create a new branch from this checkout, you may do so\n>>   (now or later) by using -b with the checkout command again. Example:\n>>     git checkout -b <new_branch_name>\n>>   HEAD is now at f4855d4... 1\n>\n> The problem of this warning is, that it does not actually say anything about\n> detached and that potential commit won't update the ref being checked out.\n\n\"Being detached\" is a rather geekish synonym to \"which isn't a\nlocal branch\", isn't it?\n"},{"id":"47329","messageId":"20070714083843.GA3678@efreet.light.src","threadId":"8964","inReplyTo":"7v1wfe4op5.fsf@assigned-by-dhcp.cox.net","subject":"Re: pushing changes to a remote branch","fromName":"Jan Hudec","fromEmail":"bulb@ucw.cz","sentAt":"2007-07-14T08:38:43Z","receivedAt":"2007-07-14T08:38:43Z","isPatch":false,"sender":{"key":"bulb@ucw.cz","avatar":null},"body":"On Wed, Jul 11, 2007 at 14:26:14 -0700, Junio C Hamano wrote:\n> Jan Hudec <bulb@ucw.cz> writes:\n> \n> >>   $ git checkout origin/master\n> >>   Note: moving to \"origin/master\" which isn't a local branch\n> >>   If you want to create a new branch from this checkout, you may do so\n> >>   (now or later) by using -b with the checkout command again. Example:\n> >>     git checkout -b <new_branch_name>\n> >>   HEAD is now at f4855d4... 1\n> >\n> > The problem of this warning is, that it does not actually say anything about\n> > detached and that potential commit won't update the ref being checked out.\n> \n> \"Being detached\" is a rather geekish synonym to \"which isn't a\n> local branch\", isn't it?\n\nIn a sense, no, it is not. \"Being detached\" is a synonym of \"HEAD is not\nsymbolic ref\". The current warning does not really convey the information,\nthat the ref being checked out will not be updated. Maybe it could be\nextended along the lines of following patch.\n\nHm, it will say the same when checking out with commit name, which does not\nmake sense much, though.\n\n-->8--\nExtend the detached head warning in checkout.\n\nThe warning when detaching head now explicitely states that ref being checked\nout will not be updated.\n---\n git-checkout.sh |    3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/git-checkout.sh b/git-checkout.sh\nindex 17f4392..502b2be 100755\n--- a/git-checkout.sh\n+++ b/git-checkout.sh\n@@ -178,7 +178,8 @@ then\n \tdetached=\"$new\"\n \tif test -n \"$oldbranch\" && test -z \"$quiet\"\n \tthen\n-\t\tdetach_warn=\"Note: moving to \\\"$new_name\\\" which isn't a local branch\n+\t\tdetach_warn=\"Note: moving to \\\"$new_name\\\" which isn't a local branch, so it will\n+_not_ be updated by local commits.\n If you want to create a new branch from this checkout, you may do so\n (now or later) by using -b with the checkout command again. Example:\n   git checkout -b <new_branch_name>\"\n\n-- \n\t\t\t\t\t\t Jan 'Bulb' Hudec <bulb@ucw.cz>\n"}]}