📜 ⬆️ ⬇️

A strange git bug, almost costing 10 hours of work

I spent the whole of yesterday, working hard to close a long and orderly task. It was quite late when I registered the changes and sent them to push. Git habitually cursed that he could not, because there are fresh edits. Okay, pull, push. Now it seems normal, you can go to sleep.

I will check on the test server and then send the link to my colleagues, I decided at last. The test version was showing as of yesterday. Strange, once again checked that the edits are gone, there are no fresh changes in the repository. I quickly consulted with a colleague on the subject of test glitches and decided to postpone the search for a problem until tomorrow.

The next day I once again deployed to the test server, but he stubbornly showed the old version. I decided to check with the log Gita ... my commit ... IT JUST WAS NOT! It was not anywhere, either in the local copy or in the remote one. It was not even in the source code on the disk. Files left open in the editor were empty. The only fact that connected me at that moment with reality was the compiled js-file of the project, which remained after the source code was assembled. It worked exactly the way I left it yesterday.

Having copied the most valuable thing at the moment into a separate folder, I’ve got to figure out what’s the matter, wondering how long it will take me to restore the source code from compiled js and source map.
')

What happened and how to fix it?


After some time, Google brought me to the post Recovering From a Disasterous Git-rebase mistake , in which the guy had problems just like mine. It was in the following. For an unknown reason, git rebase "lost" fresh commits and continued the chain of changes from the old commit.

Fortunately, in the case of Git, all is not lost. The .git folder contains the logs of all commits that you make to various branches. They lie along the way
 .git/logs/refs/heads/.   ,   ,       .       . 

git checkout -b itsavedmyass b6d7cf192c46
.

, . , , .
.git/logs/refs/heads/. , , . .

git checkout -b itsavedmyass b6d7cf192c46

.

, . , , .

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


All Articles