There is a .git folder on the project. How to restore the history of commits and upload the whole history to the new repository?
$ git log Fatal: Reference has invalid format: 'refs/remotes/origin/master There is a .git folder on the project. How to restore the history of commits and upload the whole history to the new repository?
$ git log Fatal: Reference has invalid format: 'refs/remotes/origin/master Look in the reflog:
git reflog There will be something like this:
4422cf4 HEAD@{1}: pull: Fast-forward 04c196f HEAD@{2}: checkout: moving from master to foo 4422cf4 HEAD@{3}: checkout: moving from feature to master 9ea2227 HEAD@{4}: reset: moving to HEAD^ b6c2674 HEAD@{5}: checkout: moving from bar to feature Find the appropriate commit message and reset to it:
git reset --hard 4422cf4 If this doesn't work, you can “fix” the .git/refs/remotes/origin/master file yourself. This file denotes a master branch. It contains a 40-character commit hash that the master branch looks at, ends with a newline.
Get the full hash of the desired commit with rev-parse :
$ git rev-parse 4422cf4 4422cf4a13713ed6c2305daeefd5105a7708fc78 Write this text to a file. You can do everything in one action:
git rev-parse 4422cf4 > .git/refs/remotes/origin/master Source: https://ru.stackoverflow.com/questions/659026/
All Articles
git logoutput anything or what happens? - user1056837.git/refs/remotes/origin/masterfile and look inside. There should be one line for 40 characters plus a line break. If it is not there, then it will be necessary to "fix". - KoVadimgit reflog? Do other people have copies of the project or on a remote repository? What did you do before the breakdown? - Nick Volynkin ♦