编程知识 cdmana.com

Git uses the reset command

Reference resources Reference 2

This command works when code is not pushed to the remote end , Multiple records that have been pushed to the remote end will appear .

git reset Undo right staged or commit Modification of

Example :

git reset HEAD CONTRIBUTING.md

git reset --soft、 --mixed And --hard
--soft Just move HEAD, The staging area and workspace remain unchanged ;
--mixed Move HEAD, Cancel everything currently held ( Staging restore ). Working directory back to git add and git commit Before the execution of the order ;
--hard Move HEAD, The staging area and workspace are all restored .

With no arguments , The default is --mixed. After restoring, the newly staged contents are restored to the workspace , You can re submit in stages . This is applicable to a previous submission error , And subsequent submission will also affect the need to re submit . Or just want to have stage Files to the staging area are restored to the workspace ( not stage When )

--soft Used to modify the most recent submission . For example, a piece of code has been submitted many times in the past, or the latest submission information has gone wrong , Want to modify the submission and then re submit .

--hard Used to discard the most recent commits .

git checkout Revocation of the stage The modification of the document of

Example : Undo the currently modified file

git checkout -- CONTRIBUTING.md

Will all have been modified but not stage The file is restored to its original appearance

git checkout .

版权声明
本文为[read]所创,转载请带上原文链接,感谢

Scroll to Top