Git 教程之查看提交历史详解
Git 查看提交历史
在使用 Git 提交了若干更新之后,又或者克隆了某个项目,想回顾下提交历史,我们可以使用 git log 命令查看。
针对我们前一章节的操作,使用
git log 命令列出历史提交记录如下:
$ git log commit 88afe0e02adcdfea6844bb627de97da21eb10af1 Merge: 14b4dca d7e7346 Author: w3cschool <w3c@w3cschool.cc> Date: Sun Mar 1 15:03:42 2015 +0800 Merge branch 'change_site' Conflicts: test.txt commit 14b4dcadbdc847207651d5a9fae0d315057f346e Author: w3cschool <w3c@w3cschool.cc> Date: Sun Mar 1 14:53:15 2015 +0800 新增加一行 commit d7e734640da06055e107eaf29cf350b3f1de1c2c Author: w3cschool <w3c@w3cschool.cc> Date: Sun Mar 1 14:48:57 2015 +0800 changed the site commit 556f0a0637978097b82287ac665a717623b21f3f Author: w3cschool <w3c@w3cschool.cc> Date: Sun Mar 1 14:40:34 2015 +0800 removed test2.txt
我们可以用 --oneline 选项来查看历史记录的简洁的版本。
$ git log --oneline 88afe0e Merge branch 'change_site' 14b4dca 新增加一行 d7e7346 changed the site 556f0a0 removed test2.txt 2e082b7 add test2.txt 048598f add test.txt 85fc7e7 test comment from w3cschool.cc
这告诉我们的是,此项目的开发历史。
我们还可以用 --graph 选项,查看历史中什么时候出现了分支、合并。以下为相同的命令,开启了拓扑图选项:
$ git log --oneline --graph * 88afe0e Merge branch 'change_site' |\ | * d7e7346 changed the site * | 14b4dca 新增加一行 |/ * 556f0a0 removed test2.txt * 2e082b7 add test2.txt * 048598f add test.txt * 85fc7e7 test comment from w3cschool.cc
现在我们可以更清楚明了地看到何时工作分叉、又何时归并。
你也可以用 '--reverse'参数来逆向显示所有日志。
$ git log --reverse --oneline 85fc7e7 test comment from w3cschool.cc 048598f add test.txt 2e082b7 add test2.txt 556f0a0 removed test2.txt d7e7346 changed the site 14b4dca 新增加一行 88afe0e Merge branch 'change_site'
如果只想查找指定用户的提交日志可以使用命令:git log --author , 例如,比方说我们要找 Git 源码中 Linus
提交的部分:
$ git log --author=Linus --oneline -5 81b50f3 Move 'builtin-*' into a 'builtin/' subdirectory 3bb7256 make "index-pack" a built-in 377d027 make "git pack-redundant" a built-in b532581 make "git unpack-file" a built-in 112dd51 make "mktag" a built-in
如果你要指定日期,可以执行几个选项:--since 和 --before,但是你也可以用 --until 和 --after。
例如,如果我要看 Git 项目中三周前且在四月十八日之后的所有提交,我可以执行这个(我还用了 --no-merges
选项以隐藏合并提交):
$ git log --oneline --before={3.weeks.ago} --after={2010-04-18} --no-merges 5469e2d Git 1.7.1-rc2 d43427d Documentation/remote-helpers: Fix typos and improve language 272a36b Fixup: Second argument may be any arbitrary string b6c8d2d Documentation/remote-helpers: Add invocation section 5ce4f4e Documentation/urls: Rewrite to accomodate transport::address 00b84e9 Documentation/remote-helpers: Rewrite description 03aa87e Documentation: Describe other situations where -z affects git diff 77bc694 rebase-interactive: silence warning when no commits rewritten 636db2c t3301: add tests to use --format="%N"
以上就是Git 教程之查看提交历史详解的内容,更多相关文章请关注PHP中文网(www.php.cn)!

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

要通过 Git 下载项目到本地,请按以下步骤操作:安装 Git。导航到项目目录。使用以下命令克隆远程存储库:git clone https://github.com/username/repository-name.git

更新 git 代码的步骤:检出代码:git clone https://github.com/username/repo.git获取最新更改:git fetch合并更改:git merge origin/master推送更改(可选):git push origin master

Git Commit 是一种命令,将文件变更记录到 Git 存储库中,以保存项目当前状态的快照。使用方法如下:添加变更到暂存区域编写简洁且信息丰富的提交消息保存并退出提交消息以完成提交可选:为提交添加签名使用 git log 查看提交内容

解决 Git 下载速度慢时可采取以下步骤:检查网络连接,尝试切换连接方式。优化 Git 配置:增加 POST 缓冲区大小(git config --global http.postBuffer 524288000)、降低低速限制(git config --global http.lowSpeedLimit 1000)。使用 Git 代理(如 git-proxy 或 git-lfs-proxy)。尝试使用不同的 Git 客户端(如 Sourcetree 或 Github Desktop)。检查防火

要删除 Git 仓库,请执行以下步骤:确认要删除的仓库。本地删除仓库:使用 rm -rf 命令删除其文件夹。远程删除仓库:导航到仓库设置,找到“删除仓库”选项,确认操作。

Git 代码合并过程:拉取最新更改以避免冲突。切换到要合并的分支。发起合并,指定要合并的分支。解决合并冲突(如有)。暂存和提交合并,提供提交消息。

在开发一个电商网站时,我遇到了一个棘手的问题:如何在大量商品数据中实现高效的搜索功能?传统的数据库搜索效率低下,用户体验不佳。经过一番研究,我发现了Typesense这个搜索引擎,并通过其官方PHP客户端typesense/typesense-php解决了这个问题,大大提升了搜索性能。

在 Git 中提交空文件夹,只需遵循以下步骤:1. 创建空文件夹;2. 将文件夹添加到暂存区;3. 提交更改,并输入提交消息;4. (可选)将更改推送到远程存储库。注意:空文件夹的名称不能以 . 开头,如果文件夹已存在,需要使用 git add --force 添加。
