zoukankan      html  css  js  c++  java
  • git,目录,暂存,仓库

    工作目录回滚:
    [root@zxw6 zxw]# echo "zhao" >> test
    [root@zxw6 zxw]# git status
    # On branch master
    # Changes not staged for commit:
    # (use "git add <file>..." to update what will be committed)
    # (use "git checkout -- <file>..." to discard changes in working directory)
    #
    # modified: test
    #
    no changes added to commit (use "git add" and/or "git commit -a")
    [root@zxw6 zxw]# git checkout -- test
    [root@zxw6 zxw]# cat test
    zhaoxiaowei

     

    暂存区域回滚:
    [root@zxw6 zxw]# echo "zhao" >> test
    [root@zxw6 zxw]# git add . 提交到暂存区域
    [root@zxw6 zxw]# git status
    # On branch master
    # Changes to be committed:
    # (use "git reset HEAD <file>..." to unstage)
    #
    # modified: test
    #
    [root@zxw6 zxw]# git reset HEAD test
    Unstaged changes after reset:
    M test
    [root@zxw6 zxw]# cat test
    zhaoxiaowei
    zhao
    [root@zxw6 zxw]# git status 回滚到工作目录
    # On branch master
    # Changes not staged for commit:
    # (use "git add <file>..." to update what will be committed)
    # (use "git checkout -- <file>..." to discard changes in working directory)
    #
    # modified: test
    #
    no changes added to commit (use "git add" and/or "git commit -a")
    [root@zxw6 zxw]# git checkout -- test 再次回滚
    [root@zxw6 zxw]# cat test
    zhaoxiaowei

    仓库回滚:
    [root@zxw6 zxw]# echo "zhao" >> test
    [root@zxw6 zxw]# git add . 提交到暂存
    [root@zxw6 zxw]# git commit -m "v4" 提交到仓库
    [master d837a86] v4
    1 file changed, 1 insertion(+)
    [root@zxw6 zxw]# git log
    commit d837a868493c2209f0caa303a8339c9caed34ba2
    Author: Your Name <you@example.com>
    Date: Mon Jul 15 07:56:18 2019 -0400

    v4

    commit c866a1da7133f5c7fc04ccc6bc862f7e4dee478f
    Author: Your Name <you@example.com>
    Date: Mon Jul 15 07:18:45 2019 -0400

    v1
    [root@zxw6 zxw]# git reset --hard c866a1da713
    HEAD is now at c866a1d v1
    [root@zxw6 zxw]# git log
    commit c866a1da7133f5c7fc04ccc6bc862f7e4dee478f
    Author: Your Name <you@example.com>
    Date: Mon Jul 15 07:18:45 2019 -0400

    v1
    [root@zxw6 zxw]# cat test
    Zhaoxiaowei

    查看所有版本:
    [root@zxw6 zxw]# git reflog
    c866a1d HEAD@{0}: reset: moving to c866a1da713
    d837a86 HEAD@{1}: commit: v4
    c866a1d HEAD@{2}: reset: moving to c866a1da7133
    f38ef58 HEAD@{3}: commit: v3
    a81565c HEAD@{4}: commit: v2
    c866a1d HEAD@{5}: commit (initial): v1

    [root@zxw6 zxw]# git reset --hard f38ef58
    HEAD is now at f38ef58 v3
    [root@zxw6 zxw]# git log
    commit f38ef582124460bebb4e9113c9abfa4a3195e69c
    Author: Your Name <you@example.com>
    Date: Mon Jul 15 07:28:29 2019 -0400

    v3

    commit a81565c30c5a39f0bf3a309cb52bbd75942e5bdc
    Author: Your Name <you@example.com>
    Date: Mon Jul 15 07:27:55 2019 -0400

    v2

    commit c866a1da7133f5c7fc04ccc6bc862f7e4dee478f
    Author: Your Name <you@example.com>
    Date: Mon Jul 15 07:18:45 2019 -0400

    v1

  • 相关阅读:
    2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛 C: Coconut
    2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛 A: Banana
    第2周项目1c++语言中函数参数传递的三种方式
    第2周项目2程序的多文件组织
    【BZOJ 3224】普通平衡树
    【POJ 1741】Tree
    浅谈树分治
    【luogu 2709 / BZOJ 3781】小B的询问
    【luogu 1972 / BZOJ 1878】HH的项链
    【BZOJ 3339 / BZOJ 3585 / luogu 4137】Rmq Problem / mex
  • 原文地址:https://www.cnblogs.com/itzhao/p/11301110.html
Copyright © 2011-2022 走看看