How to recover the code? Git noob

How to recover the code?

I executed the following two commands:

git log -all -p
git reflog

I see that my code is there. However, I am not sure how to restore them.

Here is what reflog shows:

23f50a6 HEAD@{0}: checkout: moving from filling-in-layout to master
39bdf8c HEAD@{1}: commit: Finished layout and routes
2ca279b HEAD@{2}: commit: Removed default Rails page
23f50a6 HEAD@{3}: checkout: moving from master to filling-in-layout
23f50a6 HEAD@{4}: merge static-pages: Fast-forward
436aabd HEAD@{5}: checkout: moving from static-pages to master
23f50a6 HEAD@{6}: commit: Done with static pages
c11e8b0 HEAD@{7}: commit: Added a Pages controller
436aabd HEAD@{8}: checkout: moving from master to static-pages
436aabd HEAD@{9}: commit: Improved the README and .Gitignore
a1d135d HEAD@{10}: commit (initial): Initial commit v.3

After I checked, as shown in HEAD@{0}, all my code was deleted and returned to status again HEAD@{9}. I am such a noob in this and I am learning RoR with the Hartl Tutorial. But, following his advice, all the work that I have done over the past 5 hours is gone. They must be in fixation HEAD@{1}. Ah, I don't know what I'm talking about. Please, help:/

Any help would be greatly appreciated!

+3
source share
3 answers

, , git reset --hard - git, . , , , .

- , ; ; git merge filling-in-layout . , , :

         static-pages
            master      filling-in-layout
o------o------X------o------o

X . , .

(.. ), git reset --hard , , . , , , ,

            master
o------o------X
 \
  \  filling-in-layout
   o------o

git reset --hard filling-in-layout () , , .

+6

:

git reset --hard HEAD@{1}
+4

: master, fill-in-layout static-pages. , .

, , .

, :

git checkout filling-in-layout

, , , , HEAD @{4}:

git checkout master
git merge filling-in-layout

Please note: if you are already on the main computer and have local changes in your files on disk, you want to either commit the changes, undo them, or copy them before merging.

+1
source

All Articles