2016-01-05 67 views
1

我对这个git很陌生,就我的经验而言,我从来没有遇到过这样的事情。git commit,git stash和git stash pop后不会出现提交的文件

我有多个本地分支,我经常切换,因为我使用一个组,并使用其他分支作为参考。

在这种情况下,我的一个朋友承诺并将某些东西推送到他的分支,他建议我们看看。

所以我在自己的分支上进行了修改,但像往常一样,有些Xcode文件在我们打开它们时会自动编辑它们,所以我认为它们是一个好主意, )并在稍后处理它们,这样我就可以检查我的朋友的分支并获取更新。

完成后,我切换回我的分支,并做了git stash pop,并检出了并非真正重要的文件。

然后我注意到我创建的文件不见了。

我试图做一个git revert但它什么也没做,不是我理解发生了什么事情。

这里是我把命令列表:

git add Integra-Geochemistry/Controllers/WaterSamplingFormOneViewController.swift 
git add Integra-Geochemistry/Views/WaterSamplingFormOneView.swift 
git add Integra-Geochemistry/Xibs/WaterSamplingFormOne.xib 
git status 
git commit -m "Initial commit - added WaterSamplingForm" 
git status 
git branch 
git branch dev/surface-thermal-sampling 
git checout dev/surface-thermal-sampling 
git checkout dev/surface-thermal-sampling 
git stash 
git status 
git checkout dev/surface-thermal-sampling 
git pull origin dev/surface-thermal-sampling 
git branch 
git status 
git branch 
git checkout dev/watersampling 
git status 
git stash pop 
git checkout Integra-Geochemistry/Xibs/AddRadonFormView.xib 
git checkout Integra-Geochemistry/Xibs/RadonReadingFormFourView.xib 
git checkout Integra-Geochemistry/Xibs/RadonReadingFormThreeView.xib 
git checkout Integra-Geochemistry/Xibs/RadonReadingFormTwoView.xib 
git checkout Integra-Geochemistry/Xibs/RadonReadingFormView.xib 
git log 
git revert 63947089d3479fff91ae4fb2ba5d59bd39d0c30d 

仅供参考,这里的日志文件(以后我做的混帐复归)

commit 8f5a3b8a4db5bad0a750ba08cd2d5b6a8a2fe18e 
Author: <--------> 
Date: Tue Jan 5 17:28:19 2016 +0800 

    Revert "Initial commit - added WaterSamplingForm" 

    This reverts commit 63947089d3479fff91ae4fb2ba5d59bd39d0c30d. 

commit 63947089d3479fff91ae4fb2ba5d59bd39d0c30d 
Author: <--------> 
Date: Tue Jan 5 17:13:35 2016 +0800 

    Initial commit - added WaterSamplingForm 

我已经做了很多承诺的,推动和转换分支,但我从来没有像这样消失在我身上。

有没有机会我的文件可以恢复?我讨厌重新开始。谢谢。

+0

相关问:HTTP://计算器。com/questions/34519665/how-to-move-head-forward/34519716#34519716 – CodeWizard

回答

0

有没有机会我的文件可以恢复?我讨厌重新开始。谢谢。

是的。

类型git reflog并签出您想要返回的期望提交。

基本上你在Git里执行的每一个动作都是存储数据的,你可以在reflog中找到它。

Git很难不丢失你的数据,所以如果出于某种原因,你认为它有可能,你可以使用git reflog来挖掘它。

这意味着您可以将其用作安全网:您不应该担心合并,重新绑定或其他某个操作会破坏您的工作,因为您可以使用此命令再次找到它。

enter image description here

了解更多关于它here

+0

感谢您的建议。尽管如此,我所做的文件仍然不会在Xcode中显示,也不会显示在它们各自的目录中。我检查了其他分支,他们不是他们的(在“初始提交 - 添加WaterSamplingForm”之前的日志站点)。 –

+0

作为一种良好的做法,请勿使用存储使用分支。如果yu没有提交你的文件,你可能想尝试使用fsck来恢复它们。 http://stackoverflow.com/questions/34572728/lost-all-my-staged-but-uncommited-modifications-after-git-revert-abort-command/34572818#34572818 – CodeWizard

+0

我确实提交了文件(“初始提交 - 添加WaterSamplingForm“),我只是不想检查或忽略不需要的文件(出于某种原因,在Xcode中查看xib意味着您对其进行了更改)。我试过fsck,但他们仍然不会出现。 –

相关问题