【问题标题】:Get first line by git log with a single command on windows在 Windows 上使用单个命令通过 git log 获取第一行
【发布时间】:2019-08-12 13:14:49
【问题描述】:

似乎是一个非常简单的问题,已经让我发疯了。尝试通过以下命令从提交列表中获取第一行:

E:\Repos\reports>git log --oneline --reverse origin/master..feature/a123

得到以下输出

d8c38ac Dummy change to invoke deploy
aaca9eb (HEAD -> feature/a123, origin/feature/a123) Add transation isolation

然后尝试做

E:\Repos\reports>git log --oneline --reverse 原点/master..feature/a123 -n 1

不管我是否使用--reverse,我总是得到aaca9eb commit

【问题讨论】:

    标签: windows git git-log


    【解决方案1】:

    是的,这令人沮丧,因为提交数量的限制 (-n) 发生在 --reverse 之前。

    虽然你可以把它放在尾巴上:

    git log --oneline --reverse origin/master..feature/a123 | tail -1
    

    【讨论】:

    • 我在 Windows 上。
    • @DmitrijKultasev 是的,我没有问,但它在 Windows cmd 中不起作用。但是,您可以在“Git for Windows”的 git bash 终端中执行此操作。
    • @DmitrijKultasev 下载适用于 Windows 的“tail”命令行工具。 windows-commandline.com/tail-command-for-windows
    • @Mr.Black 嘿,这很整洁。喜欢它。
    • 我将在 powershell 中执行此操作。我只是认为可能有本机 git 命令。
    猜你喜欢
    • 2016-03-25
    • 1970-01-01
    • 1970-01-01
    • 2015-05-31
    • 1970-01-01
    • 2021-01-10
    • 2015-07-01
    • 2012-06-15
    • 2017-04-23
    相关资源
    最近更新 更多