gpt4 book ai didi

git - 如何在 git log 中显示 SVN 修订号?

转载 作者:IT王子 更新时间:2023-10-29 00:59:29 26 4
gpt4 key购买 nike

我正在将我的 git 日志自定义为全部在 1 行中。具体来说,我添加了以下别名:

lg = log --graph --pretty=format:'%Cred%h%Creset - %C(yellow)%an%Creset - %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative

因此,当我运行 git lg 时,我看到以下内容:

* 41a49ad - zain - commit 1 message here (3 hours ago)
* 6087812 - zain - commit 2 message here (5 hours ago)
* 74842dd - zain - commit 3 message here (6 hours ago)

但是,我也想在其中添加 SVN 修订号,所以它看起来像:

* 41a49ad - r1593 - zain - commit 1 message here (3 hours ago)

正常的 git log 会显示 SVN 修订号,所以我相信这一定是可能的。我该怎么做呢?

最佳答案

考虑命令 git svn

  • 它具有与git log相似的日志功能: git svn 日志
  • 它有 find-rev选项(从 SHA1 key 检索 SVN 修订版)(在 git 1.6.0 中引入)

不过,我不确定您是否可以将这两个选项组合在一个命令行中。
一个脚本(有点像 this one 这不是您想要的,但仍然可以提供一些想法)可能是合适的。


sdaau添加 in the comments :

An example of this:

git svn find-rev $(git log --max-count 1 --pretty=format:%H)

Adversus添加 in the comments :

Note that find-rev searches in the current branch, so if you're in master and rxyz happened in a branch, find-rev will not find it.
You can give -B (before) or -A (after) options for a wider search, see git svn find-rev man page section.

关于git - 如何在 git log 中显示 SVN 修订号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2870506/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com