How git withdraws a submission
Made a commit in the master branch??!!
git add index.js Git commit - M 'presumes to be in the development branch, which is actually a commit in the master branch'
There has never been such a mistake before. Even if it appears, it’s direct
pushAnd then again
resetRoll back and then again
How to solve this situation properly
resetThree parameters of
While resetting the position, only keep
Working TreeThe contents of the working directory, but the staging area and
RepositoryContent changes in and
resetThe target node is the same, so the change files between the original node and the reset node will be placed in the
Working TreeIn the working directory.
Simply put: don’t delete the workspace change code, but undo
commit, and cancel
Git reset -- mixed head ^ and git reset head^
HEAD^ HEAD~1 HEAD~2among
HEAD^ HEAD~1Same as previous version,
HEAD~2For the last two versions, that is, two commit, and so on
If you need to undo the modification again
git checkout index.js
While resetting the position, keep
working TreeContents of working directory and staging area, only
resetThe target node is consistent, so the change files between the original node and the reset node will be put into the staging area.
Simply put: do not delete workspace change code, undo
At the same time of resetting the position, directly
working TreeWorking directory, staging area and
repositoryAll reset to target
resetThe content of the node.
Simply put: delete workspace change code, undo
This operation will be directly restored to the previous one
After doing the above
git push origin -f
Generally, please make a record when recalling the rollback operation
commitVersion number of in case of error again