The version rollback of the git command: (concept) When the idea was developed, it was the workspace (files not added), add --> temporary storage area, commit --> local warehouse push --> remote warehouse
did not push to remote warehouse:
git log (check the commit information, get the commitId)
git reset --soft {commitId} Used to withdraw the files submitted to the local warehouse to the temporary storage area. Files added will not be restored to
unadd git reset --mixed {commitId} Used to withdraw files submitted to the local warehouse to the workspace, and files added will be restored to
unadd git reset --hard {commitId} (completely return If you return to a certain version of the local warehouse, the local source code will also become the content of the previous version. If it has not been added to the temporary storage area, it will not affect, but the newly added and modified files and codes will be deleted. (Reset), use with caution!)
"HEAD" in git reset --hard HEAD must be uppercase. HEAD^ means the last version, HEAD^^ means the last version, the upper 100 versions can be written as HEAD plus 100 consecutive ^, or it can be written as: HEAD~100.
*If you want to get the latest code on the remote server, you can get the latest commitId on the remote warehouse, and then use git reset --hard {commitId}
//single file
git add tset.java to add the new file to the temporary storage Area//Open git Bash
git rm --cached tset.java in the directory where tset.java is located or
git restore --staged tset.java //Remove the added files from the temporary storage area
git checkout tset.java //Restore the specified files in the temporary storage area to the workspace
Version rollback of git command
Guess you like
Origin blog.csdn.net/xc_nostalgia/article/details/107980747
Recommended
Ranking