Git advanced command (1) (undo delete operation)

Git's undo operation

1. Undo the content submitted to the repository
Use the git commit -amend command, as shown in the figure:
write picture description here
Description: Undo the content submitted to the repository, and resubmit the contents of the staging area to the repository (premise: to Submit the contents of the workspace to the staging area first), of course, we can also not modify the file, just modify the description information
2. To undo our modifications to the workspace,
use the git checkout –fileName(eq:index.html) command, As shown in the figure:
write picture description here
Afterwards, our misoperation will be revoked
. To put it bluntly, the content of our staging area will be overwritten with the content of the file in our workspace, which is not so tall.
Description: git checkout – . Undo all our misoperations
3. To revoke the file we submitted to the staging area,
use the git reset HEAD fileName (eq:index.html) command, as shown in the figure:
write picture description here
Description: HEAD here is our head pointer, which is our latest submitted version, we can also Replace our HEAD with another version number, but without affecting the contents of the workspace

Deletion of Git files

1. Delete the files in the workspace and our staging area.
Use the git rm fileName (eq:index.html) command, as shown in the figure:
write picture description here
Note here that if our files are modified, we cannot use this command to Delete, as shown in the figure:
write picture description here
2. Only delete the files in the temporary storage area
Use the git rm –cached fileName(index.html) command, as shown in the figure:
write picture description here
3. Delete the files in the temporary storage area and the files in the workspace ( The file has been modified)
Use the git rm -f fileNamee(index.html) command, as shown in the figure:
write picture description here
4. Rename the workspace file
Use the mv index.html index1.html command, as shown in the figure:
write picture description here

write picture description here
Here we can find that the renaming operation actually deletes a file and creates another file.
5. Use the git mv style.css style1.css command to rename the workspace file and the staging area file
, as shown in the figure:
write picture description here
The results show that
write picture description here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325502429&siteId=291194637