git log
View submitted history related parameters:
parameter | The effect |
---|---|
p | Shows the differences introduced by each commit in patch format. |
stat | Display statistics on file changes submitted each time. |
shortstat | Show only the last number of rows in –stat modify add remove statistics. |
name-only | Only the list of modified files is displayed after the information has been submitted. |
name-status | Displays the list of newly added, modified, and deleted files. |
abbrev-commit | Only the first few characters of all 40 characters in the SHA-1 checksum are displayed. |
relative-date | Display the date in a short relative time (such as “2 weeks ago”) rather than in a full format. |
graph | Display the branch and merge history as an ASCII graphic next to the log. |
pretty | Display historical commit information in other formats. Options available include oneline, short, full, fuller, and Format (to define your own format). |
oneline | Pretty =oneline — short for abbrev-commit. * |
Pay attention to
How to exit git log
=> Press Q in English
git revert
git reset
The Git Revert command works like reset, but in a different way. Typically, reset reverses the changes by moving the branch pointer elsewhere in the COMMIT chain. The Revert command adds a new commit at the end of the chain to “undo” the change.
Git rebase
The rebase operation lines up the local unpushed fork commit history;
The purpose of Rebase is to make it easier to see changes in historical commits, since forked commits require a three-way comparison.
Discard the commit to remotely discover the last committed content
Git push origin branch name -f (the branch code is behind the remote code)
Note: This method requires the VIm command window (enter I to enter editing mode, change the pick before the version to drop or d, delete the record, then press ESC, enter :wq to save and exit the git log, it is found that the latest commit has been deleted)
Git push origin branch name -f (branch code behind remote)
Git Revert the latest commitid and git push origin branch name.
Now that there are three test commits, the requirement is to remove the “third test commit.”
This is the first modification
Changed “Download Data Detail” => “Download Data Detail 111”
The second modification
I copied two lines too many
The third modification
A row of data is deletedSee the log
Method 1 git rebase
git rebase -i 9e7f6f52041d989ef44ba12c750ba9185630cc8b
Copy the code
How do I start typing VIM in Git Rebase?
Reference connection 1: How do I start typing VIM in Git Rebase? Git rebase: git rebase: git rebase: git rebase
Method 2: Use git reset to go back to the location of the second commit
Execute the code
git reset --hard 9e7f6f52041d989ef44ba12c750ba9185630cc8b
Copy the code
git push origin product-zy -f
Copy the code
The resulting code
At this point we have gone back to the “third test commit”
View the Git log timeline
Method 3: Use Git revet
Reprovide the COMMIT for change 4Changed code area:
At this point, you will find that the code has a new change record, change 4 code record is rolled back
You can see that a new revert record has been added and that the COMMIT message for change 4 is still there
Extension:
What if we need to go back to a change that is not currently the most recent, and there are several histories between the current version and the current version that need to be saved? To kill B, git rebase –onto A, B, C
1. Try Git Rebase
Add change 5, and then our goal is to keep all records except for change 2That is, remove the code for change 2
Command line (temporary solution)
git rebase -i 9d30a942d64140072a888e308f880c25030d5d08
Copy the code
The execution has created a conflict that needs to be resolvedThe operation principle of this step can be referenced:Git undo Commit
conclusion
rebase | revert | reset | |
---|---|---|---|
Submit the record | To get rid of | A revert change exists and has been added | Roll back to COMMIT. The default mode is commit. |
submissions | To get rid of | To get rid of | Keep the source code, default way. |
If above have wrong welcome correction