One, git version comparison
Move command
At this time, you can enter the following move command:
Press the j button to move down one line, and press the k button to move up one line.
f represents the next page (the content of a window); b represents the move to the previous page.
d means move down half a page; u means move up half a page.
Jump command
Is it possible to jump directly to the beginning and the end?
Press g to go to the first line, press G to go to the last line.
Enter the number 3 first, and then press g to go to the third line.
Search command
To see if the content of a certain function has changed, you can use the search command.
Enter a slash (/) or question mark (?), followed by the search keyword:
Exit and help
Enter q after the colon to exit diff; enter h to enter the help interface, you will see many commands and functions, enter q to exit the help interface.
Second, the last commit of the git modification
git commit --amend
After entering the interface, press i (insert) to modify the submission instructions, and press shift + z + z to exit editing and save after modification
If you need to modify the submission instructions, you can execute the git commit --amend -m "new submission instructions" command.
If you don’t want to save, press q! to exit
Attached picture: Understanding of –amend
Three, git deletion and accidental deletion recovery
If you delete the local file and want to retrieve it, execute git checkout – README.md (file name) to restore the files in the temporary storage area to the working directory
The git rm file name can remove the specified file from the temporary storage area and the local directory (rm is actually the abbreviation of remove)
If you want to remove it from the warehouse, you can execute the git reset --soft HEAD~ command to roll back the snapshot to the previous location, and then resubmit
If I add a test.py file to the working directory, and then execute the git add test.py command to add it to the temporary storage area, at this time I modify the content of the test.py file, then the temporary storage area and the working directory are two Different test.py files, execute git rm test.py Git will stop you at this time, execute git rm -f test.py to delete both the local and temporary areas; if you only want to delete files in the temporary area (reserve Working directory), then you can execute the git rm --cached filename command to achieve the purpose
Fourth, the renaming of git
If you want to rename the file game.py to wordgame.py, then take the following command
git mv game.py wordgame.py