Git - 入门到熟悉_日志管理

Posted 小小工匠

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Git - 入门到熟悉_日志管理相关的知识,希望对你有一定的参考价值。

文章目录


Pre

Git - 入门到熟悉_Git基本概念与核心命令

Git - 入门到熟悉_分支管理

Git - 入门到熟悉_远程仓库管理

在使用 Git 提交了若干更新之后,又或者克隆了某个项目,想回顾下提交历史,可以使用 git log 命令查看。


常用命令

#查看当前分支下所有提交日志
git log
#查看当前分支下所有提交日志
git log branch
# 单行显示日志
git log --oneline
# 比较两个版本的区别
git log master..experiment

#以图表的方式显示提交合并网络
git log --pretty=format:'%h %s' --graph

演示


artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/gitProject (master)
$ git log
commit 36a0f0253e4967e30dbcc7689eff872f72138444 (HEAD -> master, tag: tag_0816, origin2/master, origin/master)
Author: yangshangwei <yswcomeon@gmail.com>
Date:   Tue Aug 16 05:18:54 2022 +0800

    8 commit

commit b685db4861c9d8ba7a4f251f3aa26ebca8b7a271
Author: yangshangwei <yswcomeon@gmail.com>
Date:   Tue Aug 16 04:57:25 2022 +0800

    7 commit

commit 9f302ffcd77e703b02e9d185d085484f1e298c0a
Author: yangshangwei <yswcomeon@gmail.com>
Date:   Mon Aug 15 00:34:03 2022 +0800

    第四次提交

commit 2d23d8a4a8b9f79f893ce7ef594624929b57d31c (tag: 4_commit)
Author: yangshangwei <yswcomeon@gmail.com>
Date:   Mon Aug 15 00:24:25 2022 +0800

    第三次提交

commit 5e6d25b9e0f1bae23ce98facecf79ad4e97df174
Author: yangshangwei <yswcomeon@gmail.com>
Date:   Sun Aug 14 23:55:34 2022 +0800

    第二次提交

commit 4ac59bd9186592662350d23f1cdfbe5c4f21f329
Author: yangshangwei <yswcomeon@gmail.com>
Date:   Sun Aug 14 23:02:58 2022 +0800

    init commit

artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/gitProject (master)
$ git branch
* master

artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/gitProject (master)
$ git log master
commit 36a0f0253e4967e30dbcc7689eff872f72138444 (HEAD -> master, tag: tag_0816, origin2/master, origin/master)
Author: yangshangwei <yswcomeon@gmail.com>
Date:   Tue Aug 16 05:18:54 2022 +0800

    8 commit

commit b685db4861c9d8ba7a4f251f3aa26ebca8b7a271
Author: yangshangwei <yswcomeon@gmail.com>
Date:   Tue Aug 16 04:57:25 2022 +0800

    7 commit

commit 9f302ffcd77e703b02e9d185d085484f1e298c0a
Author: yangshangwei <yswcomeon@gmail.com>
Date:   Mon Aug 15 00:34:03 2022 +0800

    第四次提交

commit 2d23d8a4a8b9f79f893ce7ef594624929b57d31c (tag: 4_commit)
Author: yangshangwei <yswcomeon@gmail.com>
Date:   Mon Aug 15 00:24:25 2022 +0800

    第三次提交

commit 5e6d25b9e0f1bae23ce98facecf79ad4e97df174
Author: yangshangwei <yswcomeon@gmail.com>
Date:   Sun Aug 14 23:55:34 2022 +0800

    第二次提交

commit 4ac59bd9186592662350d23f1cdfbe5c4f21f329
Author: yangshangwei <yswcomeon@gmail.com>
Date:   Sun Aug 14 23:02:58 2022 +0800

    init commit

artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/gitProject (master)
$ git log --oneline
36a0f02 (HEAD -> master, tag: tag_0816, origin2/master, origin/master) 8 commit
b685db4 7 commit
9f302ff 第四次提交
2d23d8a (tag: 4_commit) 第三次提交
5e6d25b 第二次提交
4ac59bd init commit

artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/gitProject (master)
$ git log --pretty=format:'%h %s' --graph
* 36a0f02 8 commit
* b685db4 7 commit
* 9f302ff 第四次提交
* 2d23d8a 第三次提交
* 5e6d25b 第二次提交
* 4ac59bd init commit

artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/gitProject (master)
$ git branch dev

artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/gitProject (master)
$ git branch
  dev
* master

artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/gitProject (master)
$ git checkout dev
Switched to branch 'dev'

artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/gitProject (dev)
$ ls
README.MF  src/

artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/gitProject (dev)
$ echo 'devv' >README.MF

artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/gitProject (dev)
$ git status
On branch dev
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   README.MF

no changes added to commit (use "git add" and/or "git commit -a")

artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/gitProject (dev)
$ git add -A ;
warning: LF will be replaced by CRLF in README.MF.
The file will have its original line endings in your working directory

artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/gitProject (dev)
$ git status
On branch dev
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   README.MF


artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/gitProject (dev)
$ git commit -am 'dev firs commit';
[dev 188ec16] dev firs commit
 1 file changed, 1 insertion(+), 1 deletion(-)

artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/gitProject (dev)
$ git push ;
fatal: The current branch dev has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin dev


artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/gitProject (dev)
$  git push --set-upstream origin dev
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 281 bytes | 281.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-6.4]
remote: Create a pull request for 'dev' on Gitee by visiting:
remote:     https://gitee.com/yangshangwei/gitProject/pull/new/yangshangwei:dev...yangshangwei:master
To https://gitee.com/yangshangwei/gitProject.git
 * [new branch]      dev -> dev
Branch 'dev' set up to track remote branch 'dev' from 'origin'.

artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/gitProject (dev)
$ git log dev
commit 188ec1684503dcdea074fc27d2d2718065a83b4e (HEAD -> dev, origin/dev)
Author: yangshangwei <yswcomeon@gmail.com>
Date:   Wed Aug 17 00:41:59 2022 +0800

    dev firs commit

commit 36a0f0253e4967e30dbcc7689eff872f72138444 (tag: tag_0816, origin2/master, origin/master, master)
Author: yangshangwei <yswcomeon@gmail.com>
Date:   Tue Aug 16 05:18:54 2022 +0800

    8 commit

commit b685db4861c9d8ba7a4f251f3aa26ebca8b7a271
Author: yangshangwei <yswcomeon@gmail.com>
Date:   Tue Aug 16 04:57:25 2022 +0800

    7 commit

commit 9f302ffcd77e703b02e9d185d085484f1e298c0a
Author: yangshangwei <yswcomeon@gmail.com>
Date:   Mon Aug 15 00:34:03 2022 +0800

    第四次提交

commit 2d23d8a4a8b9f79f893ce7ef594624929b57d31c (tag: 4_commit)
Author: yangshangwei <yswcomeon@gmail.com>
Date:   Mon Aug 15 00:24:25 2022 +0800

    第三次提交

commit 5e6d25b9e0f1bae23ce98facecf79ad4e97df174
Author: yangshangwei <yswcomeon@gmail.com>
Date:   Sun Aug 14 23:55:34 2022 +0800

    第二次提交

commit 4ac59bd9186592662350d23f1cdfbe5c4f21f329
Author: yangshangwei <yswcomeon@gmail.com>
Date:   Sun Aug 14 23:02:58 2022 +0800

    init commit

artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/gitProject (dev)
$ git log --pretty=format:'%h %s' --graph
* 188ec16 dev firs commit
* 36a0f02 8 commit
* b685db4 7 commit
* 9f302ff 第四次提交
* 2d23d8a 第三次提交
* 5e6d25b 第二次提交
* 4ac59bd init commit

artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/gitProject (dev)
$

artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/gitProject (dev)
$


artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/gitProject (dev)
$


artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/gitProject (dev)
$

artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/gitProject (dev)
$ git log dev
commit 188ec1684503dcdea074fc27d2d2718065a83b4e (HEAD -> dev, origin/dev)
Author: yangshangwei <yswcomeon@gmail.com>
Date:   Wed Aug 17 00:41:59 2022 +0800

    dev firs commit

commit 36a0f0253e4967e30dbcc7689eff872f72138444 (tag: tag_0816, origin2/master, origin/master, master)
Author: yangshangwei <yswcomeon@gmail.com>
Date:   Tue Aug 16 05:18:54 2022 +0800

    8 commit

commit b685db4861c9d8ba7a4f251f3aa26ebca8b7a271
Author: yangshangwei <yswcomeon@gmail.com>
Date:   Tue Aug 16 04:57:25 2022 +0800

    7 commit

commit 9f302ffcd77e703b02e9d185d085484f1e298c0a
Author: yangshangwei <yswcomeon@gmail.com>
Date:   Mon Aug 15 00:34:03 2022 +0800

    第四次提交

commit 2d23d8a4a8b9f79f893ce7ef594624929b57d31c (tag: 4_commit)
Author: yangshangwei <yswcomeon@gmail.com>
Date:   Mon Aug 15 00:24:25 2022 +0800

    第三次提交

commit 5e6d25b9e0f1bae23ce98facecf79ad4e97df174
Author: yangshangwei <yswcomeon@gmail.com>
Date:   Sun Aug 14 23:55:34 2022 +0800

    第二次提交

commit 4ac59bd9186592662350d23f1cdfbe5c4f21f329
Author: yangshangwei <yswcomeon@gmail.com>
Date:   Sun Aug 14 23:02:58 2022 +0800

    init commit

artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/gitProject (dev)
$ git log dev --oneline
188ec16 (HEAD -> dev, origin/dev) dev firs commit
36a0f02 (tag: tag_0816, origin2/master, origin/master, master) 8 commit
b685db4 7 commit
9f302ff 第四次提交
2d23d8a (tag: 4_commit) 第三次提交
5e6d25b 第二次提交
4ac59bd init commit

artisan@LAPTOP-JF3RBRRJ MINGW64 /d/opt/gitdemo/gitProject (dev)
$ git blame README.MF
188ec168 (yangshangwei 2022-08-17 00:41:59 +0800 1) devv


以上是关于Git - 入门到熟悉_日志管理的主要内容,如果未能解决你的问题,请参考以下文章

Git - 入门到熟悉_TAG管理

Git - 入门到熟悉_TAG管理

Git - 入门到熟悉_远程仓库管理

Git - 入门到熟悉_远程仓库管理

Git - 入门到熟悉_分支管理

Git - 入门到熟悉_分支管理