Git快捷键

自定义

1
2
3
4
5
6
7
8
9
# tag
git tag # 查看tag列表
git show 0.1.0 # 查看tag信息
git tag -a 0.1.0 -m <message> <commitID> # 创建tag
git tag -d 0.1.0 # 删除tag
git push origin --tags # 推送所有tag
git push origin 0.1.0 # 推送指定tag
# 删除远程tag0.1.0
先从本地删除,然后 git push origin :refs/tags/0.1.0

Shell快捷键

1
2
3
4
5
6
7
# 光标移动
ctrl+ a / e #移到行首/行尾
ctrl+ f / b #向右/左移动
ctrl+ h #向左删除
ctrl+ p / n #上/下一个命令
ctrl+ r #搜索历史命令
ctrl+ u #删除当前行

Vim

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# 移动
h 光标向左移动一个字符
j 或 Ctrl + J 光标向下移动一行
k 或 Ctrl + P 光标向上移动一行
l 光标向右移动一个字符
0 (数字 0)移动光标至本行开头
$ 移动光标至本行末尾
^ 移动光标至本行第一个非空字符处
w 向前移动一个词 (上一个字母和数字组成的词之后)
W 向前移动一个词 (以空格分隔的词)
5w 向前移动五个词
b 向后移动一个词 (下一个字母和数字组成的词之前)
B 向后移动一个词 (以空格分隔的词)
5b 向后移动五个词
G 移动至文件末尾
gg 移动至文件开头

# 浏览文档
( 跳转到上一句
) 跳转到下一句
{ 跳转到上一段
} 跳转到下一段
[[ 跳转到上一部分
]] 跳转到下一部分
[] 跳转到上一部分的末尾
][ 跳转到上一部分的开头

# 插入
a 在光标后插入文本
A 在行末插入文本
i 在光标前插入文本
o (小写字母 o)在光标下方新开一行
O (大写字母 O)在光标上方新开一行
:r [filename] 在光标下方插入文件 [filename] 的内容
:r ![command] 执行命令 [command] ,并将输出插入至光标下方

# 删除
x 删除光标处字符
dw 删除一个词
d0 删至行首
d$ 删至行末
d) 删至句末
dgg 删至文件开头
dG 删至文件末尾
dd 删除该行
3dd 删除三行

# 搜索/替换
/search_text 检索文档,在文档后面的部分搜索 search_text
?search_text 检索文档,在文档前面的部分搜索 search_text
n 移动到后一个检索结果
N 移动到前一个检索结果
:%s/original/replacement 检索第一个 “original” 字符串并将其替换成 “replacement”
:%s/original/replacement/g 检索并将所有的 “original” 替换为 “replacement”
:%s/original/replacement/gc 检索出所有的 “original” 字符串,但在替换成 “replacement” 前,先询问是否替换
r{text} 将光标处的字符替换成 {text}
R 进入覆写模式,输入的字符将替换原有的字符

# 复制/粘贴
yy 复制当前行至存储缓冲区
["x]yy 复制当前行至寄存器 x
p 在当前行之后粘贴存储缓冲区中的内容
P 在当前行之前粘贴存储缓冲区中的内容
["x]p 在当前行之后粘贴寄存器 x 中的内容
["x]P 在当前行之前粘贴寄存器 x 中的内容

# 撤销/重做
u 撤销最后的操作
Ctrl+r 重做最后撤销的操作

# 保存/退出
:q 退出 Vim,如果文件已被修改,将退出失败
:w 保存文件
:w new_name 用 new_name 作为文件名保存文件
:wq 保存文件并退出 Vim
:q! 退出 Vim,不保存文件改动
ZZ 退出 Vim,如果文件被改动过,保存改动内容
ZQ 与 :q! 相同,退出 Vim,不保存文件改动

item快捷键

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# add
alias ga='git add'
alias gaa='git add --all'
alias gapa='git add --patch'
alias gau='git add --update'
alias gav='git add --verbose'

# branch
alias gb='git branch'
alias gba='git branch -a'
alias gbd='git branch -d'
alias gbD='git branch -D'
alias gbl='git blame -b -w'
alias gbnm='git branch --no-merged'
alias gbr='git branch --remote'
alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)'
alias gbda='git branch --no-color --merged | command grep -vE "^(\+|\*|\s*($(git_main_branch)|development|develop|devel|dev)\s*$)" | command xargs -n 1 git branch -d'

alias gco='git checkout'
alias gcb='git checkout -b'
alias gcm='git checkout $(git_main_branch)'
alias gcd='git checkout develop'

alias gsw='git switch'
alias gswc='git switch -c'

# commit
alias gc='git commit -v'
alias gc!='git commit -v --amend'
alias gcn!='git commit -v --no-edit --amend'
alias gca='git commit -v -a'
alias gca!='git commit -v -a --amend'
alias gcan!='git commit -v -a --no-edit --amend'
alias gcans!='git commit -v -a -s --no-edit --amend'
alias gcam='git commit -a -m'
alias gcsm='git commit -s -m'
alias gcs='git commit -S'

# diff
alias gd='git diff'
alias gdca='git diff --cached'
alias gdcw='git diff --cached --word-diff'
alias gds='git diff --staged'
alias gdt='git diff-tree --no-commit-id --name-only -r'
alias gdw='git diff --word-diff'

# pull
alias gl='git pull'
alias gup='git pull --rebase'
alias gupv='git pull --rebase -v'
alias gupa='git pull --rebase --autostash'
alias gupav='git pull --rebase --autostash -v'
alias glum='git pull upstream $(git_main_branch)'
alias ggpull='git pull origin "$(git_current_branch)"'

# push
alias gp='git push'
alias gpd='git push --dry-run'
alias gpf='git push --force-with-lease'
alias gpf!='git push --force'
alias gpoat='git push origin --all && git push origin --tags'
alias gpu='git push upstream'
alias gpv='git push -v'
alias ggpush='git push origin "$(git_current_branch)"'
alias gpsup='git push --set-upstream origin $(git_current_branch)'

# log
alias glg='git log --stat'
alias glgp='git log --stat -p'
alias glgg='git log --graph'
alias glgga='git log --graph --decorate --all'
alias glgm='git log --graph --max-count=10'
alias glo='git log --oneline --decorate'
alias glog='git log --oneline --decorate --graph'
alias gloga='git log --oneline --decorate --graph --all'
alias glp="_git_log_prettily"
alias glol="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'"
alias glols="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --stat"
alias glod="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset'"
alias glods="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short"
alias glola="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --all"

# merge
alias gm='git merge'
alias gmom='git merge origin/$(git_main_branch)'
alias gmum='git merge upstream/$(git_main_branch)'
alias gma='git merge --abort'

# rebase
alias grb='git rebase'
alias grba='git rebase --abort'
alias grbc='git rebase --continue'
alias grbd='git rebase develop'
alias grbi='git rebase -i'
alias grbm='git rebase $(git_main_branch)'
alias grbs='git rebase --skip'

# reset
alias grh='git reset'
alias grhh='git reset --hard'
alias groh='git reset origin/$(git_current_branch) --hard'
alias gru='git reset --'

# revert
alias grev='git revert'

# status
alias gst='git status'
alias gss='git status -s'
alias gsb='git status -sb'

# stash
alias gstc='git stash clear'
alias gstd='git stash drop'
alias gstl='git stash list'
alias gstp='git stash pop'
alias gsts='git stash show --text'
alias gstu='git stash --include-untracked'
alias gstall='git stash --all'

Karabinder

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 移动
hjkl - ⬅️⬇️⬆️➡️
e #下一个单词
b #上一个单词
0 ,{ #行首
$ ,} #行尾
^ #在行首空格前后跳转
gg #文件头
G #文件尾
y
c
x
dd,de,db,d0,d^ d$ dgg dG d{ d}
yy y+移动
cc c+移动
0%