table of Contents
Git is a distributed version control tool for managing any small or large engineering project agilely and efficiently. I believe everyone knows this point. However, if I say it is open source, have you suddenly become interested? Open source? Yes, what we discussed today has nothing to do with this (hehe). Git is often used in our daily development work. As long as you are typing code, you are dealing with Git almost all the time. Of course, we will also encounter various problems in this process.
Hello, everyone, I am Data-Mining, alias liuzhen007 (Chinese Bond, a Bond typing code), today I encountered another Git-related problem.
The thing is like this, in order to achieve the download function of the object storage service, I modified a lot of code on a Git branch, but the more the change, the more chaotic, it is inevitable. Sometimes typing code is like drawing, drawing and drawing, and I don’t know what I’m drawing.
A: Overturned, start over!
D:. . .
D: Can't do it. . .
The code reset failed. . .
awkward. . . China Bond wants to undo the current revisions, so why can't it do it!
At that time, China Bond executed the following orders:
git reset --hard
As a result, Git prompts that the following error has occurred:
fatal: Could not reset index file to revision'HEAD'
In fact, there are many reasons for this problem, including but not limited to the following solutions.
Method 1: Run Terminal or Shell terminal as an administrator.
This question is easy to understand and relatively common. Therefore, I recommend giving priority to this solution.
Method two, delete the project and clone again.
Haha, is this method very thorough? It directly eliminates Git's own problems. If we encounter a problem that cannot be solved by Method 1, then it is recommended to use this method directly.
It can be considered the ultimate time-saving trick.
So, are there any problems that cannot be solved by this method?
Yes, such as the problems encountered in method three. . .
Method three, clean up the disk space.
You may ask: Can this method be used?
Yes, the machine is running out of disk space, which is what I encountered today.
After checking the reason, it turned out that the log of the docker container filled up the disk.
You can refer to the following command to view the disk usage:
find /home/boom/docker/containers/ -name *-json.log |xargs du -sh
I don’t know if I don’t check it.
The log of a container actually ran 341G! ! !
The screenshot is proof, I didn't blame anyone wrong:
Through the above figure, we only know that the log file of a container is so big, but which container is it?
We continue to investigate based on the ID.
Use the following command:
docker container ls | grep 25ddfc
Oh, it turned out to be a container called digibird/ordovician-usm.
Through the log information analysis, we can know that this container generated 341G logs after only 23 hours of startup, my God! Is this container specialized in producing logs?
Stop it, delete the log and let's talk about it!
Well, at this point, we finally solved the case. . . Spreading flowers + applause. . . Comment + Like + Favorite. . .
Finally, what are the reasons you have encountered that caused the failure of Git to reset the code, please comment and leave a message!