我有一个我正在进行的项目,我从一个本地回购开始。我最近有人创建了一个github仓库,我将本地仓库上传到github(有各种各样的错误和建议,但最终看起来就像是在那里。)做完之后,从源头/主人那里拉,我注意到我是错过了一个月左右的工作。显然我的过程消灭了一个名为“echo”的分支。
我现在想要从丢失的分支中恢复这些更改。这是当前的图片:
git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
git branch
* master
git checkout echo
error: pathspec 'echo' did not match any file(s) known to git.
和
git log --pretty=format:"%h - %an, %s"
5825339 - David Rogers, Merge branch 'master' of https://github.com/...
3c41742 - Someone Else, Initial commit
6db6654 - unknown, Labels V 1.1.8
2085c27 - David Rogers, Remove site 29 XML subdirectory from installer
956c939 - David Rogers, Update user settings on upgrade
1c39bbc - David Rogers, Update user settings on upgrade
ac48392 - David Rogers, Initial commit
感谢这里精彩的网页:http://gitready.com/intermediate/2009/02/09/reflog-your-safety-net.html, 我可以看到更大的图景:
git reflog
5825339 HEAD@{0}: pull origin master: Merge made by the 'recursive' strategy.
6db6654 HEAD@{1}: checkout: moving from echo to master
b7642f4 HEAD@{2}: pull origin master: Merge made by the 'recursive' strategy.
bb4cbe2 HEAD@{3}: commit: before github
9288903 HEAD@{4}: commit: before github
2e8336a HEAD@{5}: commit: prior to github
6db6654 HEAD@{6}: checkout: moving from master to echo
6db6654 HEAD@{7}: commit: Labels V 1.1.8
2085c27 HEAD@{8}: commit: Remove site 29 XML subdirectory from installer
956c939 HEAD@{9}: commit: Update user settings on upgrade
1c39bbc HEAD@{10}: commit: Update user settings on upgrade
ac48392 HEAD@{11}: commit (initial): Initial commit
(请注意“结帐:从主人转移到回声。”)无论如何,它看起来像我缺少的分支的头部是bb4cbe2。问题是,如何恢复工作并将其归结为原点/主人?
此外,
git fsck --lost-found
Checking object directories: 100% (256/256), done.
dangling commit b7642f4fa87f52b0991f88ce08e29d5aaa43edd3
我是从git reset --hard bb4cbe2
如果我这样做,我会:
git reset --hard bb4cbe2
HEAD is now at bb4cbe2 before github
git status
On branch master
Your branch and 'origin/master' have diverged,
and have 3 and 2 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
Untracked files:
(use "git add <file>..." to include in what will be committed)
xxx.vshost.exe.manifest
xxx/bin/Release/
xxx/obj/Release/
xxx/Release/
nothing added to commit but untracked files present (use "git add" to track)
看起来文件很好。怎么办?我是否从原产地拉出来?然后推到原点?
我应该提一下,我在git reset
之前有一个完整的磁盘备份。
大卫
答案 0 :(得分:0)
我会在原点/主人身上做一个改变,然后推送到原点/主人。如果您不关心丢失提交历史记录,也可以合并到master上。
答案 1 :(得分:0)
如果您在发布的reflog中看到了之前所需的状态,则可以从reflog中查看该状态,例如:
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetChangeRequest *createAssetRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:image.image];
} completionHandler:nil];
然后,这会将您带到由reflog识别的该州的分支机构。如果那是在你的拉动之前那可能是你想要的。
答案 2 :(得分:0)
git checkout b7642f4fa87f52b0991f88ce08e29d5aaa43edd3
这将检查悬空提交。如果这是你想要的东西,那么只需从该提交创建一个新的分支,你就是金色的。如果不是,那么你可能想要更好地解释你的问题。