git中神秘的消失分支 [英] mysterious vanishing branches in git
问题描述
这是我执行的一些git动作。正如你所看到的,我做了一个新的分支,修改了我的文件,然后提交了更改。改回到另一个分支后,希望合并,我刚刚开始工作的分支消失了。
有谁知道我如何从fixed_merge_branch恢复文件?我吓坏了!
1.9.2@whisperme$ git branch fixed_merge_conflict
1.9.2@whisperme$ git checkout fixed_merge_conflict
M ArtworkViewController.h
M ArtworkViewController.m
M ArtworkViewController.xib
M类/ DFRAppDelegate.h
M类/ DFRAppDelegate.m
M类/ WorkGalleryViewController.m
M类/ 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
fr.lproj / Localizable.strings
切换到分支'fixed_merge_conflict'
1.9.2@whisperme$ git add。
1.9.2@whisperme$ cd Classes /
1.9.2@whisperme$ git add。
1.9.2@whisperme$ cd ..
1.9.2@whisperme$ git add -u
1.9.2@whisperme$ git status
#目前没有任何分支机构。
#要提交的更改:
#(使用git reset HEAD< file> ...停用)
#
#modified:ArtworkViewController.h
#modified:ArtworkViewController.m
#modified:ArtworkViewController.xib
#modified:Classes / DFRAppDelegate.h
#modified:Classes / DFRAppDelegate.m
#modified:Classes / WorkGalleryViewController.m
#修改:DFR.xcodeproj / project.pbxproj
#修改:Data.h
#修改:Data.m
#修改:MainWindow.xib
#modified:cn.lproj / Localizable.strings
#modified:en.lproj / Localizable.strings
#
#未记录文件:
#(使用git add<文件> ...包含在将要提交的内容中)
#
#fr.lproj /
1.9.2@whisperme$ git commit -m通过合并重新做了更改搞砸了
[detached HEAD 858491f]重新做了改变,合并拧了损失
更改了12个文件,110个插入(+),50个删除( - )
1.9.2@whisperme$ git checkout d evelop
以前的HEAD位置是858491f ...重新做了改变,合并失败了
转换到分支'develop'
1.9.2@whisperme$ git branch
artwork_model
artwork_model_localisation
artwork_screen
* develop
记录器
master
start_artwork_model
1.9.2@whisperme$ git merge fixed_merge_conflict
致命:'' fixed_merge_conflict'不指向提交
1.9.2@whisperme$ git checkout fixed_merge_conflict
错误:pathspec'fixed_merge_conflict'与git已知的任何文件都不匹配。
1.9.2@whisperme$ git checkout fixed_merge_conflict
错误:pathspec'fixed_merge_conflict'与git已知的任何文件都不匹配。
1.9.2@whisperme$ git branch
artwork_model
artwork_model_localisation
artwork_screen
* develop
logger
master
start_artwork_model
1.9.2@whisperme$ git checkout
1.9.2@whisperme$ git branch
artwork_model
artwork_model_localisation
artwork_screen
* develop
logger
master
start_artwork_model
1.9.2@whisperme$ pwd
/ Users / tristan / Documents / DFR
1.9.2@whisperme$
$ c $ 我不完全明白为什么分支'消失',但不用担心,你的文件没有。
你可以通过很多方式找到它们:
- 当您离开匿名分支时,可以使用由
git checkout
打印的消息:
- 您可以使用
git reflog
并找到文件的提交。
然后你可以运行这个来重新创建分支:
git checkout 858491f -b fixed_merge_conflict
然后您可以进行合并:
git checkout develop
git merge fixed_merge_conflict
或者如果你不关心分支,你可以一步完成合并:
git merge 858491f
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 to merge, the branch I was just working on disappeared.
Does anyone know how I can recover the files from fixed_merge_branch? I'm freaking out!
1.9.2@whisperme$ git branch fixed_merge_conflict
1.9.2@whisperme$ 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'
1.9.2@whisperme$ git add .
1.9.2@whisperme$ cd Classes/
1.9.2@whisperme$ git add .
1.9.2@whisperme$ cd ..
1.9.2@whisperme$ git add -u
1.9.2@whisperme$ 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/
1.9.2@whisperme$ 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(-)
1.9.2@whisperme$ git checkout develop
Previous HEAD position was 858491f... re-did changes lost by merge screw up
Switched to branch 'develop'
1.9.2@whisperme$ git branch
artwork_model
artwork_model_localisation
artwork_screen
* develop
logger
master
start_artwork_model
1.9.2@whisperme$ git merge fixed_merge_conflict
fatal: 'fixed_merge_conflict' does not point to a commit
1.9.2@whisperme$ git checkout fixed_merge_conflict
error: pathspec 'fixed_merge_conflict' did not match any file(s) known to git.
1.9.2@whisperme$ git checkout fixed_merge_conflict
error: pathspec 'fixed_merge_conflict' did not match any file(s) known to git.
1.9.2@whisperme$ git branch
artwork_model
artwork_model_localisation
artwork_screen
* develop
logger
master
start_artwork_model
1.9.2@whisperme$ git checkout
1.9.2@whisperme$ git branch
artwork_model
artwork_model_localisation
artwork_screen
* develop
logger
master
start_artwork_model
1.9.2@whisperme$ pwd
/Users/tristan/Documents/DFR
1.9.2@whisperme$
Thanks a bunch!
解决方案 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
这篇关于git中神秘的消失分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!