Git rollback merge
The merge operation is often rolled back when branch merge errors occur. This article introduces the rollback method of merge.
The command
git reflog
: Displays the version number of the last committed record for the merge operationGit reset -- Hard version number
: This allows you to roll back to the state before merge
The sample
Merge dev into master branch by mistake
-
First of all git reflog
Ee0ee93 HEAD@{0}: merge dev: merge made by the 'recursive' strategy. 7335548 HEAD@{1}: checkout: moving from dev to masterCopy the code
You can see that you need to roll back to the commit record 7335548.
-
Git reset –hard 7335548
7335548 HEAD@{0}: reset: moving to 7335548 ee0ee93 HEAD@{1}: merge dev: Merge made by the ‘recursive’ strategy. Copy the code
Git setup proxy
Set the agent
Git config http.proxy http://127.0.0.1:7892 git config http.proxy http://127.0.0.1:7892Copy the code
Cancel the agent
git config --unset http.proxy
git config --unset https.proxy
Copy the code
Git config –global XXX