Skip to main content

阅读代码前运行的几个 Git 命令

  1. 阅读代码前运行的几个 Git 命令

    https://piechowski.io/post/git-commands-before-reading-code/

    # 1. 查看最近一年内修改最多的 20 个文件
    git log --format=format: --name-only --since="1 year ago" | sort | uniq -c | sort -nr | head -20
    
    # 2. 按提交次数对项目提交者排名
    git shortlog -sn --no-merges
    
    # 3. 筛选特定提交信息(漏洞 / 补丁等),列出关联的最多的 20 个文件
    git log -i -E --grep="fix|bug|broken" --name-only --format='' | sort | uniq -c | sort -nr | head -20
    
    # 4. 查看代码库历史中每月的提交次数(活跃程度)
    git log --format='%ad' --date=format:'%Y-%m' | sort | uniq -c
    
    # 5. 查看最近一年内代码回滚和热修复的频次
    git log --oneline --since="1 year ago" | grep -iE 'revert|hotfix|emergency|rollback'

    #GitHub #DevOps #Shell #Doc The Git Commands I Run Before Reading Any Code
OKHK