Git 常用命令总结之查看 commit 提交日志常用参数

2020-05-21  本文已影响0人  AndyGF

在终端中我们经常需要查看代码版本历史演变过程, 此时就需要用到 git log 这个命令.
常用的 log 命令有以下几个(单独使用情况)

$ git log
$ git log --oneline
$ git log -n2
$ git log 分支名称
$ git log --all
$ git log --graph

单独使用

  1. 不加任何参数, 展示的是当前分支 commit id 编号, 作者, email, 日期, 变更的内容
$ git log
  1. 后面加上 --oneline 参数, 只展示 commit id 编号的部分和变更的内容,
$ git log --oneline
  1. 只看最近的 2 次提交,
$ git log -n2
  1. 只查看某个分支的 log
$ git log 分支名称
  1. 查看所有分支 commit 信息
$ git log --all
  1. 图形化(树形结构)展示 log,
$ git log --graph

组合使用, 可以根据自己实际情况自行组合:

$ git log -n4 --oneline
$ git log -n10 --all

更多 log 参数, 请移步 Git 官网查看

Git 官网 log 参数使用说明

补充命令

$ git checkout -b new_branch_name  base_commit_id
$ git branch -v
$ git branch -av
$ git  mv  原名  新名
$  git add -u

或者 (注意 add 后边有个 '点')

$  git add .
$ git reset --hard
$ git commit -am '改动事项说明'
$ git shortlog -sn
上一篇 下一篇

猜你喜欢

热点阅读