Re: Detached HEAD problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Apr 24, 2012 at 4:43 PM, Eugene Sajine <euguess@xxxxxxxxx> wrote:
> On Tue, Apr 24, 2012 at 4:10 PM, M Yep <myep01@xxxxxxxxx> wrote:
>> Hello
>>
>> I have been working on a project and I realized somewhere I introduced a
>> bug.
>>
>> I found the closest save point to where i was, i believe it was HEAD -2,
>> and checked it out.
>>
>> I then laid in several commits, and now i cant push
>>
>> here is a view of my history, and the commands i executed to get into this
>> state
>>
>> HISTORY (time flows up)
>>
>> * 1bc1ffb current state
>> * 735d64f
>> * 07dd73d Project working again
>> * c70627c
>> * 4c6a8ea
>> * 2828db4
>> * c38ef0b
>> | * 1815aac
>> | | * fe6e0ac Version bump
>> | | * 32de1e5 BROKE
>> | | * 528cb37 Bug introduced?
>> | |/
>> | * ef4ff7e
>> |/
>> | * ef4ff7e
>> |/
>> * 8238b14 GOOD
>> .
>> .
>> .
>>
>>
>> COMMANDS (time flows down)
>>
>> PUSH 8238b14 GOOD
>> PUSH ef4ff7e
>> PUSH 528cb37 Bug introduced?
>> PUSH 32de1e5 BROKE
>> PUSH fe6e0ac BROKE Version bump
>> CHECKOUT master -> ef4ff7e
>> CHECKOUT ef4ff7e -> dev
>> COMMIT 1815aac
>> CHECKOUT dev -> 8238b14
>> COMMIT c38ef0b
>> COMMIT 2828db4
>> COMMIT 4cba8e9
>> COMMIT c70627c
>> COMMIT 07dd73d  Project OK again
>> CHECKOUT 07dd73d -> mvp1
>> CHECKOUT mvp1 -> master
>> COMMIT 735d64f
>> COMMIT 1bc1ffb    current state
>>
>> now when i try to push:
>>
>> user@host:~/workspace/project$ git push
>> To git@xxxxxxxxxx:xxxxxxxxxxxxx.git
>>  ! [rejected]        master -> master (non-fast-forward)
>> error: failed to push some refs to 'git@xxxxxxxxxx:xxxxxxxxxxxxxxxxxxx.git'
>> To prevent you from losing history, non-fast-forward updates were rejected
>> Merge the remote changes before pushing again.  See the 'Note about
>> fast-forwards' section of 'git push --help' for details.
>>
>>
>> user@host:~/workspace/project$ git status
>> # On branch master
>> # Your branch and 'origin/master' have diverged,
>> # and have 7 and 4 different commit(s) each, respectively.
>> #
>> nothing to commit (working directory clean)
>>
>>
>> user@host:~/workspace/project$ git branch
>>  dev
>> * master
>>  mvp1
>>  noopt
>>  temp
>>
>>
>> Any help would be great.
>>
>> Thanks
>>
>> Mike
>> --
>> To unsubscribe from this list: send the line "unsubscribe git" in
>> the body of a message to majordomo@xxxxxxxxxxxxxxx
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
Your second sentence is the answer to you question:
You have moved master back a couple of commits and then started to
create new commit as those two never existed. The remote side doesn't
know about that and still points to the old commit tree.
Therefore it is not possible to move the pointer on the remote side
from its current location to your new location as it will mean that
some commits will be lost.
in order to insist on the push you might use -f, that will force push
operation and overwrite the history on the remote side.
I would recommend to be VERY careful with this option because if the
project is actively developed you might loose somebody else's commits.

Considering the rule of not overwriting published history safer
variant to me would be to rebase your current master on top of the
origin/master and then you will have a fast-forwardable update of the
remote side. That will mean that you will have the commit that
introduced the bug in the history and then you will provide a bug fix
on top of that, which is normal flow to me.

Hope that helps
Eugene
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]