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

举报
小工匠 发表于 2022/08/20 00:51:18 2022/08/20
【摘要】 文章目录 Pre常用命令演示 Pre Git - 入门到熟悉_Git基本概念与核心命令 Git - 入门到熟悉_分支管理 Git - 入门到熟悉_远程仓库管理 在使用 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


在这里插入图片描述

文章来源: artisan.blog.csdn.net,作者:小小工匠,版权归原作者所有,如需转载,请联系作者。

原文链接:artisan.blog.csdn.net/article/details/126376171

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。