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

Recommended Today

The use of progressbarcontrol, a progress bar control of devexpress – Taking ZedGraph as an example to add curve progress

scene WinForm control – devexpress18 download installation registration and use in vs: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/100061243 When using ZedGraph to add curves, the number of curves is slower if there are many cases. So in the process of adding curve, the progress needs to be displayed, and the effect is as follows     Note: Blog home page:https://blog.csdn.net/badao_liumang_qizhi […]