下边是我定义的命令别名,虽然还是记不住;
所以每次还要先执行下code ~/.gitconfig打开配置文件照着敲;
[alias]
# status
s = status
ss = status --short --branch
# stash
sh = stash
shp = stash pop
shl = stash list
shs = stash save
sha = stash apply
std = stash drop
# branch
br = branch
bra = branch -a
brm = branch -m
co = checkout
cob = checkout -b
sw = switch
swc = switch -c
# remote
ra = remote add
rao = remote add origin
ru = remote set-url
ruo = remote set-url origin
# re = remote
rev = remote -v
# fetch
fe = fetch
fep = fetch -p
fo = fetch origin
fop = fetch origin -p
# merge
mr = merge
mnc = merge --no-commit
# msq = merge --squash
# commit
ci = commit
cim = commit -m
「折腾」 git 及 docker 命令快捷输入_电脑网络_沉冰浮水:
↑ 原文链接,后续可能会修改或补充
1
vision1900 2022 年 8 月 26 日 俺也来 show 下自己的 git alias 和 function: https://github.com/librz/shell-scripts/blob/main/.zshrc#L100
|
2
wcp1231 2022 年 8 月 26 日
我只用 oh-my-zsh 提供的这两个
``` gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1' gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]"' ``` |
3
rpman 2022 年 8 月 26 日 代码经常 stash 完就永远躺在那里了 🐶
|
4
LindsayZhou 2022 年 8 月 26 日
我 gitconfig 里的 alias 只有一个比较长的,用来看分支树状图,忘了哪里抄的了。
``` lg = log --graph --abbrev-commit --decorate --all --format=format:\"%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(dim white) - %an%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n %C(white)%s%C(reset)\" ``` 其他的有自动补全和说明,按下 tab 就出来了,Arch 源里的包带了 bash completions 脚本 |
5
BeautifulSoap 2022 年 8 月 26 日
fork 用户表示自己已经废了
|
6
stoluoyu 2022 年 8 月 26 日
alias gst='git status'
alias gss='git status -s' alias gsb='git status -sb' alias ga='git add' alias gpo='git push -u origin master' alias glog="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit -- | less" 这是我自定义的,还有一堆 prezto 的 git 插件自带的,很少用。 |
7
LindsayZhou 2022 年 8 月 26 日
@LindsayZhou #4
不知道 OP 是啥系统,不过 completion 脚本在这里: https://github.com/git/git/tree/master/contrib/completion zsh 的也有,zsh 的应该是扔到 `/usr/share/zsh/site-functions/_git ` ,iirc |
8
wjfz 2022 年 8 月 26 日
@LindsayZhou
试试 git log --oneline --decorate --graph |
9
wjfz 2022 年 8 月 26 日
ohmyzsh 自带的 git 插件很好用,另外补充一点自己的
alias gcob="gco -b" alias ggpp="ggpnp" alias gx="git pull origin develop --rebase" alias gs="git show" alias gcml="gcm && gl" alias gl="git pull --rebase" |
10
LindsayZhou 2022 年 8 月 26 日
|
11
rrubick 2022 年 8 月 26 日
fork 不香吗
|
12
wdssmq OP |
13
pengtdyd 2022 年 8 月 26 日
说实话我不太喜欢用别名,我喜欢用全名。
|
14
shm7 2022 年 8 月 26 日
一般拿来一键还原修改,哈哈
|
17
fxxkgw 2022 年 8 月 26 日
我也特别喜欢用这个 然后结合 beyond compare
|
18
TerranceL 2022 年 8 月 26 日
除了 git adog 之外其他全靠补全和 ctrl+r
|
19
lujiaosama 2022 年 8 月 26 日 git stash list 躺着一堆不知道什么时候的记录.
|
20
Rache1 2022 年 8 月 26 日
别名的话,zsh 的 git alias 就挺好,Windows 下可以使用 powershell ,配合下面这个 module 来实现。
gluons/powershell-git-aliases: Oh My Zsh's Git aliases for PowerShell. https://github.com/gluons/powershell-git-aliases 自己创建别名的话,直接在 powershell 的 $profile 里面添加函数就可以。 |
21
whenov 2022 年 8 月 26 日
可惜不能只存 unstaged 区域的改动(--keep-index 也不行)
|
22
yulang 2022 年 8 月 26 日
alias.amend=commit --amend --no-edit
alias.glg=log --oneline --decorate --all --graph alias.refresh=pull --rebase --autostash upstream HEAD alias.discard=reset --hard HEAD |
23
gamesover 2022 年 8 月 27 日
如果 lz 用 vs code 的话,推荐一款插件 gitgraph
用了之后,你就从此告别自定义快捷键了 |
24
gamesover 2022 年 8 月 27 日
|