mysterious vanishing branches in git

前端 未结 2 568
被撕碎了的回忆
被撕碎了的回忆 2021-01-20 19:14

Here are some git actions I performed. As you can see, I made a new branch, modified my files, and then committed the changes. After changing back to another branch, hoping

相关标签:
2条回答
  • 2021-01-20 19:33

    for some reason, you're getting a detach head situation. I'm not entirely sure how that is caused in a regular git repo, but i've encountered it using git svn (and came up with my own solution here). It might be that the aren't --tracking the upstream repo when you create a new branch. Usually when you get a detached head, when you do a git branch, you will see (asterisk) (no branch) (don't know how to do a literal asterisk with markdown)

    0 讨论(0)
  • 2021-01-20 19:51

    Well I don't exactly see why the branch 'disappeared' but don't worry, your files didn't.

    You can find them by many means:

    • You can use the message printed by the git checkout when you left your anonymous branch: "Previous HEAD position was 858491f".
    • You can use git reflog and find the commit of your files.

    Then you can run this to recreate the branch:

    git checkout 858491f -b fixed_merge_conflict
    

    and then you can do your merge:

    git checkout develop
    git merge fixed_merge_conflict
    

    Or you can do the merge in one step if you don't care about the branch:

    git merge 858491f
    
    0 讨论(0)
提交回复
热议问题