Both commands can rollback the project. Rollback: Change the commitId and file pointed to by the current HEAD pointer to a commitId and the corresponding file status. Git reset –hard [commitId]; git checkout [commitId] [–] [file path];
Difference:
1. Reset takes the HEAD pointer and the current branch to which the pointer points, pointing to the target commitId or branch reference; Checkout only moves the HEAD pointer; the reference to the current branch does not change.
2. Checkout git status and change the status of the project or file to the commitId state. Git add and commit to create a new commitId.
Reset –hard will reset the HEAD to the current commtId. The id after the reset –hard will be lost. If you want to reset the commtId before the reset –hard rollback, you can reset the HEAD to the current commtId. Git reset –hard git reset –hard git reset –hard git reset –hard
Git reflog lists a stream record of all operations, including the reset operation. Reset id = reset ID = reset ID = reset ID = reset ID
Git reset: mixed/soft/hard; Soft: Moves only references to the HEAD pointer. Mixed (default) : Moves a reference to the HEAD pointer to make the contents of the temporary store consistent with the contents of the specified commidId location. Used to undo the add operation (git reset HEAD). Hard: move a reference to the HEAD pointer; Changes the contents of the staging area and workspace to the state specified for commitId.