如何在`git log -- dir`中显示分支?

时间:2021-03-02 16:19:19

标签: git-log

例如,我可以在 this fairly small repository 中运行 git log -- doc。但是,除非该分支的尖端在我指定的目录中进行了更改,否则不会显示这些分支。我想看到在触及目录的那个分支上的最新提交中显示的分支名称。

这类似于在 GitExtensions 中,您可以请求“目录/文件的历史记录”,同时仍然可以看到所涉及的分支。当您解决困难的合并/变基冲突或跟踪该代码中的错误时,它特别有用,因为您可以看到其他修改所在的分支,因此您还知道特定更改是否已经合并到 master 或不是。

我特别需要一种在命令行上输出它的方法,例如通过将参数传递给 git log 或自定义 shell 脚本,因为 git log 的输出被我的 git GUI ({{3} }).

1 个答案:

答案 0 :(得分:0)

我从某人那里得到了某种修复;值得一提,但它为每个提交显示一个分支,无论该分支上是否还有一些最近的提交也可见:

将 %S 添加到您的漂亮格式中,例如:

$ git log --graph --all --format='(%S) %h %s' -- doc

--all 是必不可少的,否则它总是“HEAD”。

* (refs/heads/master) 2f8558b user-changes.md: document SPDX license expressions (#683)
* (refs/heads/master) 9ad7f20 user-changes.md: Add markers for releases (#684)
| * (refs/remotes/origin/feat/crate_config) 2d08fa4 Typos
| * (refs/remotes/origin/feat/crate_config) 7b7e342 Typos
| * (refs/remotes/origin/feat/crate_config) a81c5b1 Add more documentation for crate configuration
| * (refs/remotes/origin/feat/crate_config) 3071227 Crate configuration: new manifest syntax
| * (refs/remotes/origin/feat/crate_config) 4eb8180 catalog-format-spec.md: start documentation of crate configuration
|/
* (refs/remotes/origin/feat/crate_config) a689ee3 Automatically narrow down dependencies given as "any" (#675)
* (refs/remotes/origin/feat/crate_config) 70add12 Warn about ^0.x dependencies (#669)
* (refs/remotes/origin/feat/crate_config) c763b00 Rename `alr list` to `alr crates` (#671)
* (refs/remotes/origin/feat/crate_config) 8c1e893 Clarify current behavior of actions (#672)
* (refs/remotes/origin/feat/crate_config) 185b1e1 Remove use of build/clean relocations (#667)
* (refs/remotes/origin/feat/crate_config) b9e8a64 Alire.Properties.Licenses: Add support of SPDX expression  (#629)
* (refs/remotes/origin/feat/crate_config) ccab133 Allow unknown enum values in index manifests and new `index --check` (#656)
* (refs/remotes/origin/feat/crate_config) 226e9b6 Alr.Commands.Edit: add support for custom editor (#611)
* (refs/remotes/origin/feat/crate_config) ca526e6 policies.md: add best practices (#597)
* (refs/remotes/origin/feat/crate_config) bcca503 Migration of an existing Ada/SPARK project to Alire (#598)
* (refs/remotes/origin/feat/crate_config) 7b9b7f9 Change Windows installer icon (#589)
* (refs/tags/v0.7.0) b5ad3d2 Fix the `depends-on` example in the catalog spec (#581)
* (refs/tags/v0.7.0) 378baa6 doc/getting-started.md: replace "setenv" with "printenv" (#576)
* (refs/tags/v0.7.0) e5c1ba9 Added paragraph about adding an ALR badge (#574)
* (refs/tags/v0.7.0) cc594c0 catalog-format-spec.md: fix gpr-set-externals description (#572)
* (refs/tags/v0.7.0) a824354 reviewed for English grammar, spelling, etc. (#561)
* (refs/tags/v0.7.0) dbd33cf Spelling fixes and README update (#559)
* (refs/tags/v0.7.0) fbb77b5 Update getting-started with install from binary distribution (#558)
* (refs/tags/v0.7.0) 4f6fc2c Create tarball from Alire workspace (#529)
* (refs/tags/v0.7.0) 7f1f9bc actions: rename post-compile into post-build and add pre-build (#537)
* (refs/tags/v0.7.0) be01f9c Updated documentation for new `alr publish` (#524)
* (refs/tags/v0.7.0) b372688 Added `user-changes.md` log for new `publish` feat
相关问题