Search code examples
gitbranchgitx

Git: branch has lost its history?


Something wierd has happened — my develop branch has lost all it's history till the last commit. Can anyone suggest the reason?

Last things I've done — installed that forked brotherbard GitX and started to use it (primarily for history viewing, but also tried to do on merge). But before develop was staring from master and going in parallel, 'feature-shape-fill' branch was merged into develop two times. I also did git stash in develop.

Right now git log for develop branch just shows the last commit. Doesn't says anything like 'detached'.

* I'm already afraid of GitX (official and this fork), since last weeks smth wierd happened aswell — binary .fla file hasn't been saved for the past evening in several commits. All the text files were fine, but that binary was like 4 commits behind. Other working directory wasn't updating at all while switching between branches (I was working in console and git didn't said about any error, it was fine to him). Donno if it's smth to do with gitx?

upd: Looks like the same problem mentioned here http://groups.google.com/group/gitx/browse_thread/thread/71a0f759d115fee5 Here's what I got:

$ git reflog
157cfca HEAD@{0}: checkout: moving from feature-shape-fill to develop
46a6163 HEAD@{1}: checkout: moving from develop to feature-shape-fill
157cfca HEAD@{2}: commit: Rotated drag tip
7f6c394 HEAD@{3}: commit: TextShapesCanvas is working,
4765eed HEAD@{4}: merge feature-shape-fill: Merge made by recursive.
ed44a2c HEAD@{5}: checkout: moving from feature-shape-fill to develop
46a6163 HEAD@{6}: commit: More tight packaging (thnx to TextLineMetrics),
59b6d2d HEAD@{7}: checkout: moving from develop to feature-shape-fill
ed44a2c HEAD@{8}: merge feature-shape-fill: Merge made by recursive.
67d08b3 HEAD@{9}: commit: Basic grid functionality, need to add text shapes and fix resize-generation
505479c HEAD@{10}: checkout: moving from feature-shape-fill to develop
59b6d2d HEAD@{11}: commit (amend): Simple retrovirus non-optomized algorithm
5ec1b70 HEAD@{12}: commit: Simple retrovirus non-optomized algorithm
b9eaf18 HEAD@{13}: commit: The most ugly suitable version of fill algorithm
757f1b7 HEAD@{14}: checkout: moving from feature-shape-fill-predefined to feature-shape-fill
757f1b7 HEAD@{15}: checkout: moving from feature-shape-fill to feature-shape-fill-predefined
757f1b7 HEAD@{16}: checkout: moving from feature-shape-fill-auto to feature-shape-fill
b8e284f HEAD@{17}: commit: Auto fill first steps
757f1b7 HEAD@{18}: checkout: moving from feature-shape-fill to feature-shape-fill-auto
757f1b7 HEAD@{19}: commit: Test document created, components::TextShape base draft
505479c HEAD@{20}: checkout: moving from develop to feature-shape-fill
505479c HEAD@{21}: checkout: moving from master to develop

Looks like they are not lost, but how to get my history back?


Solution

  • The picture you give shows that your develop branch is detached, if I'm not mistaken.

    Since I understand it is based on the master branch, you could put it back on the master branch:

    git rebase master develop
    

    Important: first make a backup of your original .git directory, before trying the above, as I am not sure that this will produce the result you want.

    You could also get a similar result by creating a temporary branch develop2 from master and merging develop into it:

    git checkout -b develop2 master
    git merge develop
    

    Hope this helps! I haven't tried it, so please first back up your .git directory before trying the above!