{"thread":{"id":"30327","subject":"Detached HEAD problem","startedAt":"2012-04-24T20:10:50Z","lastAt":"2012-04-24T20:45:20Z","messageCount":2,"participants":["M Yep","Eugene Sajine"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"189991","messageId":"1335298250.31016.YahooMailClassic@web125404.mail.ne1.yahoo.com","threadId":"30327","inReplyTo":null,"subject":"Detached HEAD problem","fromName":"M Yep","fromEmail":"myep01@yahoo.com","sentAt":"2012-04-24T20:10:50Z","receivedAt":"2012-04-24T20:10:50Z","isPatch":false,"sender":{"key":"myep01@yahoo.com","avatar":null},"body":"Hello\n\nI have been working on a project and I realized somewhere I introduced a\nbug.\n\nI found the closest save point to where i was, i believe it was HEAD -2,\nand checked it out.\n\nI then laid in several commits, and now i cant push\n\nhere is a view of my history, and the commands i executed to get into this\nstate\n\nHISTORY (time flows up)\n\n* 1bc1ffb current state\n* 735d64f\n* 07dd73d Project working again\n* c70627c\n* 4c6a8ea\n* 2828db4\n* c38ef0b\n| * 1815aac\n| | * fe6e0ac Version bump\n| | * 32de1e5 BROKE\n| | * 528cb37 Bug introduced?\n| |/\n| * ef4ff7e\n|/\n| * ef4ff7e\n|/\n* 8238b14 GOOD\n.\n.\n.\n\n\nCOMMANDS (time flows down)\n\nPUSH 8238b14 GOOD\nPUSH ef4ff7e\nPUSH 528cb37 Bug introduced?\nPUSH 32de1e5 BROKE\nPUSH fe6e0ac BROKE Version bump\nCHECKOUT master -> ef4ff7e\nCHECKOUT ef4ff7e -> dev\nCOMMIT 1815aac\nCHECKOUT dev -> 8238b14\nCOMMIT c38ef0b\nCOMMIT 2828db4\nCOMMIT 4cba8e9\nCOMMIT c70627c\nCOMMIT 07dd73d  Project OK again\nCHECKOUT 07dd73d -> mvp1\nCHECKOUT mvp1 -> master\nCOMMIT 735d64f\nCOMMIT 1bc1ffb    current state\n\nnow when i try to push:\n\nuser@host:~/workspace/project$ git push\nTo git@github.com:xxxxxxxxxxxxx.git\n ! [rejected]        master -> master (non-fast-forward)\nerror: failed to push some refs to 'git@github.com:xxxxxxxxxxxxxxxxxxx.git'\nTo prevent you from losing history, non-fast-forward updates were rejected\nMerge the remote changes before pushing again.  See the 'Note about\nfast-forwards' section of 'git push --help' for details.\n\n\nuser@host:~/workspace/project$ git status\n# On branch master\n# Your branch and 'origin/master' have diverged,\n# and have 7 and 4 different commit(s) each, respectively.\n#\nnothing to commit (working directory clean)\n\n\nuser@host:~/workspace/project$ git branch\n dev\n* master\n mvp1\n noopt\n temp\n\n\nAny help would be great.\n\nThanks\n\nMike\n"},{"id":"189995","messageId":"CAPZPVFZch7TzWkrYLt_MSAEDrJBGtPsf+Gvjh_e+Uk=O_tHq0Q@mail.gmail.com","threadId":"30327","inReplyTo":"CAPZPVFbv7cGzqrHrKWPig0XSbSztbGoS=Twy8xH5Ac5r0xrQFg@mail.gmail.com","subject":"Re: Detached HEAD problem","fromName":"Eugene Sajine","fromEmail":"euguess@gmail.com","sentAt":"2012-04-24T20:45:20Z","receivedAt":"2012-04-24T20:45:20Z","isPatch":false,"sender":{"key":"euguess@gmail.com","avatar":null},"body":"On Tue, Apr 24, 2012 at 4:43 PM, Eugene Sajine <euguess@gmail.com> wrote:\n> On Tue, Apr 24, 2012 at 4:10 PM, M Yep <myep01@yahoo.com> wrote:\n>> Hello\n>>\n>> I have been working on a project and I realized somewhere I introduced a\n>> bug.\n>>\n>> I found the closest save point to where i was, i believe it was HEAD -2,\n>> and checked it out.\n>>\n>> I then laid in several commits, and now i cant push\n>>\n>> here is a view of my history, and the commands i executed to get into this\n>> state\n>>\n>> HISTORY (time flows up)\n>>\n>> * 1bc1ffb current state\n>> * 735d64f\n>> * 07dd73d Project working again\n>> * c70627c\n>> * 4c6a8ea\n>> * 2828db4\n>> * c38ef0b\n>> | * 1815aac\n>> | | * fe6e0ac Version bump\n>> | | * 32de1e5 BROKE\n>> | | * 528cb37 Bug introduced?\n>> | |/\n>> | * ef4ff7e\n>> |/\n>> | * ef4ff7e\n>> |/\n>> * 8238b14 GOOD\n>> .\n>> .\n>> .\n>>\n>>\n>> COMMANDS (time flows down)\n>>\n>> PUSH 8238b14 GOOD\n>> PUSH ef4ff7e\n>> PUSH 528cb37 Bug introduced?\n>> PUSH 32de1e5 BROKE\n>> PUSH fe6e0ac BROKE Version bump\n>> CHECKOUT master -> ef4ff7e\n>> CHECKOUT ef4ff7e -> dev\n>> COMMIT 1815aac\n>> CHECKOUT dev -> 8238b14\n>> COMMIT c38ef0b\n>> COMMIT 2828db4\n>> COMMIT 4cba8e9\n>> COMMIT c70627c\n>> COMMIT 07dd73d  Project OK again\n>> CHECKOUT 07dd73d -> mvp1\n>> CHECKOUT mvp1 -> master\n>> COMMIT 735d64f\n>> COMMIT 1bc1ffb    current state\n>>\n>> now when i try to push:\n>>\n>> user@host:~/workspace/project$ git push\n>> To git@github.com:xxxxxxxxxxxxx.git\n>>  ! [rejected]        master -> master (non-fast-forward)\n>> error: failed to push some refs to 'git@github.com:xxxxxxxxxxxxxxxxxxx.git'\n>> To prevent you from losing history, non-fast-forward updates were rejected\n>> Merge the remote changes before pushing again.  See the 'Note about\n>> fast-forwards' section of 'git push --help' for details.\n>>\n>>\n>> user@host:~/workspace/project$ git status\n>> # On branch master\n>> # Your branch and 'origin/master' have diverged,\n>> # and have 7 and 4 different commit(s) each, respectively.\n>> #\n>> nothing to commit (working directory clean)\n>>\n>>\n>> user@host:~/workspace/project$ git branch\n>>  dev\n>> * master\n>>  mvp1\n>>  noopt\n>>  temp\n>>\n>>\n>> Any help would be great.\n>>\n>> Thanks\n>>\n>> Mike\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>\nYour second sentence is the answer to you question:\nYou have moved master back a couple of commits and then started to\ncreate new commit as those two never existed. The remote side doesn't\nknow about that and still points to the old commit tree.\nTherefore it is not possible to move the pointer on the remote side\nfrom its current location to your new location as it will mean that\nsome commits will be lost.\nin order to insist on the push you might use -f, that will force push\noperation and overwrite the history on the remote side.\nI would recommend to be VERY careful with this option because if the\nproject is actively developed you might loose somebody else's commits.\n\nConsidering the rule of not overwriting published history safer\nvariant to me would be to rebase your current master on top of the\norigin/master and then you will have a fast-forwardable update of the\nremote side. That will mean that you will have the commit that\nintroduced the bug in the history and then you will provide a bug fix\non top of that, which is normal flow to me.\n\nHope that helps\nEugene\n"}]}