0

我知道这里有很多问题,但没有解决方案为我工作。这是发生了什么:如何恢复从git提交更改?

我试图在我的应用程序中添加一个新功能,所以我创建了一个新的分支来实现此功能。
我完成后,我将它合并到master,删除了我测试新功能的分支,并将更改推送到存储库(bitbucket btw)。代码是正常的

然后我需要添加其他功能寿。
然后我再次创建了一个新分支,但现在我在master中测试了这个其他新功能,并让其他分支使用“正确”代码。

新功能没有工作,所以我试图去其他分支并合并到主,删除我所做的更改,它给了我一个合并冲突寿,我尝试了一切,但我只是没有'能够做到这一点。

我切换回主,并删除与正确的代码分支。
我在主人的错误代码。
我还没有推动变化,只提交,所以我试图寻找如何解决这个问题,没有工作。

我然后跑这个命令:git checkout NUMBER OF THE COMMIT

我检查了最后推提交,其中有正确的代码。

我的项目更改为正确的代码,我认为一切正常,我认为它恢复了更改。

我跑git status,那就是输出:

HEAD detached at f49fb28 
Changes not staged for commit: 
(use "git add <file>..." to update what will be committed) 
(use "git checkout -- <file>..." to discard changes in working directory) 

modified: .DS_Store 
modified: Homework.xcworkspace/xcuserdata/Henrique.xcuserdatad/UserInterfaceState.xcuserstate 

no changes added to commit (use "git add" and/or "git commit -a") 

我然后跑git add -Agit commit -m "some message"一起和它推到了回购思维,代码会得到固定在那里。它没有寿,现在我的回购和项目有相同的代码,错误的代码。是否有可能我使用RIGHT特性检出了提交,而不是错误的提交,并且我的代码恢复为完全提交?如果没有,我唯一的救赎就是重做一切。

请帮助我!

编辑:我跑git status输出功率为现在不同了:

HEAD detached from f49fb28 
Changes not staged for commit: 
(use "git add <file>..." to update what will be committed) 
(use "git checkout -- <file>..." to discard changes in working directory) 

modified: Homework.xcworkspace/xcuserdata/Henrique.xcuserdatad/UserInterfaceState.xcuserstate 

no changes added to commit (use "git add" and/or "git commit -a") 

回答

0

难道我结帐提交我用正确的功能

首先制成阅读所附评论中的完整答案。

要总结你现在可以简单地使用git reflog签出所需的提交。

这里是一个引用日志怎么会是这样的:

enter image description here