How git withdraws a submission

Time:2019-11-8

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 directpushAnd then againresetRoll back and then againpush -f

How to solve this situation properly

resetThree parameters of

--mixed(default parameter)

While resetting the position, only keepWorking TreeThe contents of the working directory, but the staging area andRepositoryContent changes in andresetThe target node is the same, so the change files between the original node and the reset node will be placed in theWorking TreeIn the working directory.

Simply put: don’t delete the workspace change code, but undocommit, and cancelgit add

Git reset -- mixed head ^ and git reset head^

HEAD^ HEAD~1 HEAD~2amongHEAD^ 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

--soft

While resetting the position, keepworking TreeContents of working directory and staging area, onlyrepositoryContent andresetThe 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, undocommitNo revocationgit add

--hard

At the same time of resetting the position, directlyworking TreeWorking directory, staging area andrepositoryAll reset to targetresetThe content of the node.

Simply put: delete workspace change code, undocommitRevokegit add

This operation will be directly restored to the previous onecommitStatus.

If alreadypush origin

After doing the above

git push origin -f

Generally, please make a record when recalling the rollback operationcommitVersion number of in case of error again