你的 git 别名是什么?

2025-06-07

你的 git 别名是什么?

介绍

我曾多次被要求分享我的.gitconfig别名并复制它。

我使用 git 别名有两个原因:

  1. 提高生产力。
  2. 记住有趣的git命令并从中学习。

我的 Gitconfig

这些是我的~/.gitconfig文件中包含的别名,供您参考:

[alias]
    a = add .
    aliases = config --get-regexp alias
    alias = ! git config --get-regexp ^alias\\. | sed -e s/^alias.// -e s/\\ /\\ $(printf \"\\043\")--\\>\\ / | column -t -s $(printf \"\\043\") | sort -k 1
    ap = add . -p
    addups = remote add upstream
    bd = branch -d
    bi = bisect
    bl = branch -l
    blr = branch -a
    br = branch -r
    ca = commit -a
    cam = commit -a -m
    ci = commit -m
    cia = commit --author='imjoseangel <anotheremail@example.com>' -m
    cm = commit
    co = checkout
    colast = checkout -
    comments = commit -m 📒Comments
    count = rev-list --count devel
    db = branch -D
    forgetAbout = rm --cached
    formatting = commit -m 💅Formatting
    fp = fetch -p
    grep = grep -F
    laf = fsck --lost-found
    last = log -1 HEAD
    latest = log -5 --pretty --oneline
    ls = ls-files --others --exclude-standard -z
    mend = commit --amend
    nb = checkout -b
    op = gc --prune=now --aggressive
    pdo = push -d origin
    pf = push --force-with-lease
    po = push origin
    pou = push --set-upstream origin
    pr = pull --rebase
    pror = remote prune origin
    prud = pull --rebase upstream devel
    prum = pull --rebase upstream main
    prune = remote update --prune
    ptag = push origin --tags
    ra = rebase --abort
    rc = rebase --continue
    refactor = commit -m 👷Refactor
    remotes = remote -v
    renb = branch -m
    rh = reset --hard
    rhh = reset --hard HEAD
    ri = rebase -i upstream/devel
    rim = rebase -i upstream/main
    rl = reflog
    rp = repack -ad
    s = status -s
    search = rev-list --all
    sh = show
    short = shortlog -sn
    sign = commit --amend --no-edit --signoff
    st = status
    stashes = stash list
    tests = commit --allow empty -m ✅Tests
    tuto = help tutorial
    tuto2 = help tutorial-2
    unstash = stash pop
    vc = clean -dfx
    wow = log --all --graph --decorate --oneline --simplify-by-decoration
Enter fullscreen mode Exit fullscreen mode

git alias添加后运行.gitconfig会显示所有别名的列表作为参考列表。

要获取更多信息,只需运行git help <command or alias>。例如:

git help st
'st' is aliased to 'status'
Enter fullscreen mode Exit fullscreen mode
git help status
Enter fullscreen mode Exit fullscreen mode

我发现有两个别名对初学者来说很有趣:

git tuto
git tuto2
Enter fullscreen mode Exit fullscreen mode

我们始终欢迎以不同方式提出意见和建议。

文章来源:https://dev.to/imjoseangel/what-are-your-git-aliases-43om
PREV
在安卓设备上安装 Linux?安卓系统上的 Linux?但为什么?如何开始?如何扩展我的权限?Linux 不错,但还有什么?社区?捐赠
NEXT
Linux - 我爱终端