Git rollback command
Revoke Operation
Basic command
$ git checkout -- [file]
When file just in work area conduct modify, Not yet(还没有) commit to temporary(暂存) storage.
You can use this command, To achieve effect(来达到效果)$ git reset HEAD
If you in work area conduct the modify, And commit to temporary. `git checkout – [file]` command
it’s invalid(就无效了).
This time should use `git reset HEAD` command to achieve effect.$ git checkout HEAD [file]
This command just will two on the top combine(组合起来), Direct use HEAD cover(覆盖) temporary and
word area.
Rollback Version
Basic command
$ git reset --hard HEAD~n
In git `HEAD` express current version. This command just rollback to `~` after appoint version.
$ git reset --hard commit_id
This command just rollback to `commitid` version.
In git see commitid the method: git reflog command.
Delete Summary
Basic command
$ git rm
This command will delete word area and temporary in content.
If delete file after, Want to get back(想要找回) just got us(刚刚被我们) delete the file.Use `git checkout HEAD [file]` command to achieve effect. Permise is(前提是) not commit.
If delete file after and commit, Then you need use `git reset –hard HEAD~1` rollback
to one on top version, Can achieve effect(可以达到效果).
本博客所有文章除特别声明外,均采用 CC BY-SA 3.0协议 。转载请注明出处!