zoukankan      html  css  js  c++  java
  • 【Git】撤销操作

    git checkout 命令

    1. 撤销对工作区的修改:是以最新的存储时间节点(add和commit)为参照,覆盖工作区对应文件file;这个命令改变的是工作区。

    git checkout  -- <file> 

    git restore 命令

    简介:git 2.23 版本新增了switch、restore命令,因为git checkout 命令职责较多、不够明确,而restore命令则专门用来还原、撤销修改等,我们这里来总结下git restore 命令的一些常用的用法。

    1.git restore撤销文件工作区的修改:

    git restore --worktree <path>

    举例说明:

    git restore --worktree test2.txt

    注意如果暂存区有该文件的修改,恢复到和暂存区一致;如果暂存区没有该文件,会将工作区的文件恢复到和最近的提交的一致。–worktree 也可以省掉,即: git restore <path> 

    2. git撤销工作区所有的文件的修改:

    git restore .

    2. git restore撤销暂存区的修改,将文件恢复到工作区去。

    git restore --staged <path>

    举例:

    git restore --staged test2.txt
    git restore --staged ‘*.txt’

    注意: git restore 撤销暂存区某些文件的修改,将这些文件恢复到工作区去

    参考资料

    1. git restore 命令的一些常用的用法

  • 相关阅读:
    Pycharm5注册方式
    五、监听共享目录文件
    三、python webservice
    二、Python安装扩展库
    一、Python安装下载
    test
    拖延
    要乐观对待生活
    乞讨者
    不要总是指责和埋怨
  • 原文地址:https://www.cnblogs.com/sunbines/p/15477751.html
Copyright © 2011-2022 走看看