Woo*_*tty 3 git version-control backup branch github
这是我执行的一些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 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$
Run Code Online (Sandbox Code Playgroud)
谢谢你!
好吧,我不清楚为什么分支'消失了'但不要担心,你的文件没有.
您可以通过多种方式找到它们:
git checkout离开匿名分支时打印的消息:"上一个HEAD位置为858491f".git reflog并查找文件的提交.然后你可以运行它来重新创建分支:
git checkout 858491f -b fixed_merge_conflict
Run Code Online (Sandbox Code Playgroud)
然后你可以做你的合并:
git checkout develop
git merge fixed_merge_conflict
Run Code Online (Sandbox Code Playgroud)
或者,如果您不关心分支,您可以一步完成合并:
git merge 858491f
Run Code Online (Sandbox Code Playgroud)