Can the git local repository only have committed content and can be restored through reflog no matter how many rebase, rest --hard and other operations are performed afterwards?
No, because reflog data is stored in the .git/logs/ directory, and git reflog operations cannot be performed when there is no content in this directory. So as long as you ensure that this directory is not cleared, you can perform dangerous operations at will? It still doesn’t work, because git will automatically run gc from time to time, and git’s gc task will delete objects that are not referenced by any commit and have existed for a period of time (several months).
Don’t just do some dangerous operations just thinking that you can recover. It will be a tragedy if one day you can’t recover. You must understand that the best effect of tools depends on people. The most important thing is to maintain the standardization of the collaboration process. . Please refer to: Git usage standard process
No, because reflog data is stored in the .git/logs/ directory, and git reflog operations cannot be performed when there is no content in this directory.
So as long as you ensure that this directory is not cleared, you can perform dangerous operations at will?
It still doesn’t work, because git will automatically run gc from time to time, and git’s gc task will delete objects that are not referenced by any commit and have existed for a period of time (several months).
Don’t just do some dangerous operations just thinking that you can recover. It will be a tragedy if one day you can’t recover. You must understand that the best effect of tools depends on people. The most important thing is to maintain the standardization of the collaboration process. .
Please refer to: Git usage standard process