Removed 2 months of working with Git. How to get them back?

I really don't know what I just did, so I'm going to give a kind of schedule.

I was first trying to create a gitHub repository. I have a folder that stores all the files from my site, and I have a .git folder. Every time I made changes, etc., and everything seemed normal.

Today I tried to merge the two branches of the project I was working on. I tried to "merge" and "reload" the commands, but I could not understand what was happening or what I was doing, so I decided that I was just starting with git.

I pulled the .git folder out of my website folder (I did not delete it, which I think could be my saving grace here). Created a new git Init in the folder and transferred the website files to it.

What when I noticed that a lot of files were uploaded. I think they are still in the first .git folder. Is there a way to restore a directory from this folder?

+3
source share
1 answer

I am surprised that you have been working with git for two months and decided that starting with the best way to recover from a failed reboot should be much easier.

You can restore old commits to a new repository without any problems.

You can add a new remote that is your old saved repository:

git remote add old /path/to/old/saved/.git

Then you can get the whole old story.

git fetch old

You can then open the history browser (for example gitk --all) to view the old history.

You can check the versions of missing files with the command, for example:

git checkout old/master -- path/to/missing/file

old/master , commit .

+3

Source: https://habr.com/ru/post/1785186/


All Articles