[Solved] Computer reboot causes broken git files

 

Error 1.
	error: bad signature
	fatal: index file corrupt
Cause.
	The index file is generally referred to as .git/index in git. This file holds information about the staging area (index information). You can see the contents of the staging area by using git ls-files --stage. This file is very important! But now it says index file corrupt, which means the file is corrupt. Fortunately, there is a way to regenerate this file: git read-tree or just git reset.
The solution.
	1. Delete or rename the .git/index file. rm -f .git/index
	2. git reset

	Solved the first problem, I thought it would be good, excited to operate again, git status appears all green files, I thought it was all to recommit under it, did not take it seriously, until I git commit when I encountered a fatal, can not go on, again oriented to Baidu.
Error 2.
	fatal: cannot lock ref 'HEAD': unable to resolve reference 'refs/heads/master': reference broken
Cause.
	Probably a computer reboot during push, resulting in a damaged git file.
Solution.
	I borrowed this method from someone else: remotely recheck out the project to a new folder, copy the new project's .git folder completely to the folder where the error occurred, and then commit and push again.

 But I wasn't as lucky as the blogger I borrowed from, and the next thing I knew, my code ...... conflicts, and the last thing I want to encounter is a conflict.
Error 3.
	Automatic merge failed; fix conflicts and then commit the result
Solution.
	emmm, you can download a Visual Studio Code to solve the conflict.

Similar Posts: