2011-01-20 4 views
3

私が行ったいくつかのgitアクションがあります。ご覧のとおり、私は新しいブランチを作成し、ファイルを変更して、変更をコミットしました。合流しようと思っている別の支店に戻った後、私が仕事をしていた支部が姿を消した。gitの不思議な消失ブランチ

fixed_merge_branchからファイルを回復する方法を知っている人はいますか?私はパニック状態だ!

[email protected]$ git branch fixed_merge_conflict 
[email protected]$ git checkout fixed_merge_conflict 
M ArtworkViewController.h 
M ArtworkViewController.m 
M ArtworkViewController.xib 
M Classes/DFRAppDelegate.h 
M Classes/DFRAppDelegate.m 
M Classes/WorkGalleryViewController.m 
M Classes/WorkGalleryViewController.xib 
M DFR.xcodeproj/project.pbxproj 
M DFRViewController.xib 
M Data.h 
M Data.m 
M MainWindow.xib 
M cn.lproj/Localizable.strings 
M en.lproj/Localizable.strings 
A fr.lproj/Localizable.strings 
Switched to branch 'fixed_merge_conflict' 
[email protected]$ git add . 
[email protected]$ cd Classes/ 
[email protected]$ git add . 
[email protected]$ cd .. 
[email protected]$ git add -u 
[email protected]$ git status 
# Not currently on any branch. 
# Changes to be committed: 
# (use "git reset HEAD <file>..." to unstage) 
# 
# modified: ArtworkViewController.h 
# modified: ArtworkViewController.m 
# modified: ArtworkViewController.xib 
# modified: Classes/DFRAppDelegate.h 
# modified: Classes/DFRAppDelegate.m 
# modified: Classes/WorkGalleryViewController.m 
# modified: DFR.xcodeproj/project.pbxproj 
# modified: Data.h 
# modified: Data.m 
# modified: MainWindow.xib 
# modified: cn.lproj/Localizable.strings 
# modified: en.lproj/Localizable.strings 
# 
# Untracked files: 
# (use "git add <file>..." to include in what will be committed) 
# 
# fr.lproj/ 
[email protected]$ git commit -m "re-did changes lost by merge screw up" 
[detached HEAD 858491f] re-did changes lost by merge screw up 
12 files changed, 110 insertions(+), 50 deletions(-) 
[email protected]$ git checkout develop 
Previous HEAD position was 858491f... re-did changes lost by merge screw up 
Switched to branch 'develop' 
[email protected]$ git branch 
    artwork_model 
    artwork_model_localisation 
    artwork_screen 
* develop 
    logger 
    master 
    start_artwork_model 
[email protected]$ git merge fixed_merge_conflict 
fatal: 'fixed_merge_conflict' does not point to a commit 
[email protected]$ git checkout fixed_merge_conflict 
error: pathspec 'fixed_merge_conflict' did not match any file(s) known to git. 
[email protected]$ git checkout fixed_merge_conflict 
error: pathspec 'fixed_merge_conflict' did not match any file(s) known to git. 
[email protected]$ git branch 
    artwork_model 
    artwork_model_localisation 
    artwork_screen 
* develop 
    logger 
    master 
    start_artwork_model 
[email protected]$ git checkout 
[email protected]$ git branch 
    artwork_model 
    artwork_model_localisation 
    artwork_screen 
* develop 
    logger 
    master 
    start_artwork_model 
[email protected]$ pwd 
/Users/tristan/Documents/DFR 
[email protected]$ 

ありがとうございました!

答えて

8

私はブランチがなぜ消えてしまったのか正確には分かりませんが、あなたのファイルはそうではありません。

あなたは多くの手段でそれらを見つけることができます:あなたはあなたの匿名のブランチを去ったとき

  • あなたはgit checkoutによって印刷されたメッセージを使用することができます。「前のヘッド位置は858491fでした」。
  • git reflogを使用して、ファイルのコミットを見つけることができます。

次にあなたがブランチを再作成し、これを実行できます。

git checkout 858491f -b fixed_merge_conflict 

、その後、あなたのマージを行うことができます。

git checkout develop 
git merge fixed_merge_conflict 

それともドン場合は、ワンステップでマージを行うことができますブランチについて気にしないでください:

git merge 858491f 
+0

ありがとうございます!それはまさに私が必要としたものでした。 – WoodenKitty

0

何らかの理由でa detach head situation。私はそれが正規のgitリポジトリでどのように引き起こされているかは完全にはわかりませんが、私はgit svnand came up with my own solution here)を使って遭遇しました。新しいブランチを作成すると、上流のレポが表示されないことがあります。通常、detached headを取得したときにgit branchを実行すると、(asterisk) (no branch)が表示されます(マークダウンでリテラルアスタリスクを実行する方法はわかりません)

関連する問題