Restore file history after pushing

I just tried transferring my files for a specific repository to my local computer in a different directory and it seems to have failed.

After copying the source files to a new folder, I used the following to try and commit to the original GitHub repository by doing the following in a new directory:

git init
git add .
git commit -m 'migration'
git remote add origin https://github.com/UN/REP.git
git push origin master

This (as I got used to git by now) threw me an error:

 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/UN/REP.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

I don’t know why this could be so, I just naively forced to click

git push -f origin master

Now, none of the files has saved its change history, since the repository shows only one (forced) commit.

Is there any way to return the change history for this repository?

/ , 1) , , 2) , , .git , , .

+1
1

, , git reflog . git ?

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

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

: , , @MichaelChirico . .

, .git c:\Michael\project.

1. : c:\temp\project.

2. .

3: c:\temp\project.

4: ls. , .git .

5: git reset --hard.

6. , c:\temp\project.

7: , git checkout .

+1

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


All Articles