• 【GIT】如何列出2个branch/tag/commitId 之间的所有commit


    复习git log的用法

    Reference:git log 用法

    语法

    git log [<options>] [<revision-range>] [[--] <path>]
    
    • 1

    常用用法

    git log foo bar ^baz # 表示 log/bar 中包含,但是baz中不包含的commit,`^` 在这里表示取反
    
    # `..` 可以实现相同的含义, 注意`..`前后不可以有空格
    git log origin..HEAD # 和下面这句表示相同的含义, 表示列出HEAD独有的commit
    git log HEAD ^origin
    
    # `...` 可以filter掉二者共同的commit, 注意`...`前后不可以有空格
    git log A B --not $(git merge-base --all A B) # 表示A/B 中包含,但是他们最新的父节点不包含的commit
    git log A...B # 表示列出A和B独有的commit
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    列出2个branch之间的所有commit

    • 有2个branch testBranch1testBranch2
    git log testBranch1 testBranch2 #  testBranch1或testBranch2 包含的commit
    git log ^testBranch1 testBranch2 # testBranch1不包含 testBranch2 包含的commit
    git log testBranch1..testBranch2 # testBranch1不包含 testBranch2 包含的commit
    git log testBranch1...testBranch2 # testBranch1或testBranch2独有的commit
    
    • 1
    • 2
    • 3
    • 4
    • 如果是远端(remote)的branch,加上origin
    git log origin/testBranch1 origin/testBranch2 #  testBranch1或testBranch2 包含的commit
    git log ^origin/testBranch1 origin/testBranch2 # testBranch1不包含 testBranch2 包含的commit
    git log origin/testBranch1..origin/testBranch2 # testBranch1不包含 testBranch2 包含的commit
    git log origin/testBranch1...origin/testBranch2 # testBranch1或testBranch2独有的commit
    
    • 1
    • 2
    • 3
    • 4

    如果远端没有这个branch,会报错。

    列出2个tag之间的所有commit

    • 有2个tag testTag1testTag2
    git log testTag1 testTag2 
    git log ^testTag1 testTag2 
    git log testTag1..testTag2 
    git log testTag1...testTag2 
    
    • 1
    • 2
    • 3
    • 4
    • 但对于tag貌似不能直接访问remote 的tag 要把tag 拉到local才可以

    列出2个commitid 之间的commit

    直接把前面的branch 或者tag 替换成commit id 的hash值即可

    输出格式化

     git log --pretty='format:%an, %h, %cs, %s' branch1..branch2
    
    • 1

    输出的格式如下:

    Author, commitId, 2023-09-27, commit msg
    
    • 1
  • 相关阅读:
    Ubuntu20.04 从头到尾完整版安装anaconda、cuda、cudnn、pytorch、paddle2.3成功记录
    数据库测试的认知和分类详解
    Java-NIO之Channel(通道)
    猿创征文|JAVA 实现《连连看》游戏
    发收一体的2.4G射频合封芯片Y62G,内置九齐MCU
    int类的前置++和后置++的实现
    Android开发之百度地图定位打卡
    一周侃 | 周末随笔及推荐
    [数据结构]数据结构简介和顺序表
    react源码中的fiber架构
  • 原文地址:https://blog.csdn.net/poinsettia/article/details/133348178