跳转至

gitignore git-delta设置

全局的在~/.gitignore,项目自己的在project/.gitignore

Bash
[user]
    email = Ken.Zhang@cixtech.com
    name = Ken.Zhang
[core]
    editor = vim
    quotepath = false
    pager = delta
[interactive]
    diffFilter = delta --color-only
[pager]
    log = delta
    show = delta
    reflog = delta
[delta]
    side-by-side = true

    dark = false
    line-numbers = true
    # 自定义行号颜色:左侧老代码用暗红,右侧新代码用暗绿,未改动用暗灰
    line-numbers-minus-style = "#ff5555"
    line-numbers-plus-style = "#50fa7b"
    line-numbers-zero-style = "#6272a4"

    # 优雅的合并冲突样式
    merge-conflict-begin-style = "#ff5555" bold
    merge-conflict-end-style = "#50fa7b" bold
    merge-conflict-ours-style = "#ffb86c" bold
    merge-conflict-theirs-style = "#8be9fd" bold


    # 自定义代码高亮风格
    syntax-theme = Dracula

    # 移除的行:深暗红背景,红色加粗文字
    minus-style = red bold "#3c1f1f"
    minus-non-em-style = red "#3c1f1f"
    minus-emphasized-style = bold red "#5c2a2a"

    # 新增的行:深暗绿背景,绿色加粗文字
    plus-style = green bold "#1f3c24"
    plus-non-em-style = green "#1f3c24"
    plus-emphasized-style = bold green "#2a5c34"


    # 在 diff 中显示 hunk 头部(如函数名、类名),并用蓝色修饰
    hunk-header-style = syntax bold italic
    hunk-header-decoration-style = blue box

    # 开启 grep 高亮
    grep-match-line-style = syntax
    grep-match-word-style = syntax bold underline

# 自动将 commit hash、文件路径转换为可点击的超链接
    hyperlinks = true  # github/gitlab会自动识别,不需要hyperlinks-commit-link-format
#    hyperlinks-commit-link-format = "https://codereview.cixtech.com/q/{commit}"
#   hyperlinks-commit-link-format = "https://github.com{commit}"
#    hyperlinks-file-link-format = "vscode://file/{path}:{line}" # 甚至能直接唤起 VS Code
[grep]
    lineNumber = true

建议这两项根据项目进行调整

Bash
# 自动将 commit hash、文件路径转换为可点击的超链接
    hyperlinks = true
    # hyperlinks-commit-link-format 特殊项目,才要设置,gitlab/github/Bitbucketw
    hyperlinks-commit-link-format = "https://codereview.cixtech.com/q/{commit}"
    #   hyperlinks-commit-link-format = "https://github.com{commit}"
    #    hyperlinks-file-link-format = "vscode://file/{path}:{line}" # 甚至能直接唤起 VS Code

不要设置 hyperlinks-commit-link-format,只启用 hyperlinks,Delta 会读取当前仓库的 Git remote,自动识别 GitHub/GitLab/Bitbucket 仓库并生成 commit 链接。官方文档也说明,commit hash 默认会根据远端仓库生成链接。

github项目可以这样

Text Only
hyperlinks-commit-link-format = "https://github.com/zhangkangcool/zhangkangcool.github.io/commit/{commit}
或者只设置
    hyperlinks = true,不设置hyperlinks-commit-link-format,会自动识别