git log命令

  1. 在提交很多次后,我们可以使用git log命令来查看提交的信息

    1. git log

    image.png

  2. 这其中就包含了commit的一个SHA-1 hash值;作者;日期;提交备注(commit)

image.png

  1. git log常用命令组合 | 命令 | 说明 | | —- | —- | | git log —patch -2 | —patch可以显示每次提交的diff,-n可以指定最近几次commit | | git log —stat | 显示每次commit的统计信息,比如修改了几个文件,删除了几个文件,添加了几个文件 | | git log —oneline —abbrev-commit —graph | 可以看到整个commit树结构,包括如何合并的,就显示每个commit的SHA-1和提交说明,同时SHA-1显示短值 |

版本回退

  1. 版本回退使用的是reset命令,常用的命令组合如下 | 命令 | 说明 | | —- | —- | | git reset —hard HEAD^ | 回退上一个版本 | | git reset —hard HEAD~5 | 回退HEAD之前的倒数第5个commit的状态 | | git reset —hard d324644 | 指定一个commit hash值,回退到指定的版本 |
  1. 现在又对这个版本不满意 要回到原来最新的呢个版本该怎么办,使用git reflog可以所有的操作记录,然后在使用git reset —hard commithash,回退到指定的的版本
    git reflog
    
    image.png