[Git] Alias
[Git] alias
有時候指令太長,就會覺得想偷懶,所以來打造自己的 Git 快速鍵吧!順便就筆記一下。
.gitconfig
要做 alias,就需要去修改 .gitconfig 檔案。通常 .gitconfig 檔案會位於帳號的跟目錄下。
$ ls -al ~/
...
-rw-rw-r-- 1 robert robert 245 7月 13 04:55 .gitconfig
...
修改 .gitconfig
在檔案裡,添加 [alias]
,將一些想做 alias
的命令,依序填寫進去。
[alias]
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
lo = log --oneline --graph
ci = commit
co = checkout
br = branch
ba = branch -a
st = status
rt = remote
rtv = remote -v
測試 alias 指令
測試 git log
$ git lg
commit xxxxx
Author: oooo
Date: Fri Jul 13 03:42:27 2018 +0800
...
commit xoxoxoxoxo
Author: oooo
Date: Thu Jul 12 20:35:02 2018 +0800
...
測試 git log --oneline
$git lo
8b7a80f ...
3451bc9 ...
af0e2d6 ...
abc6b88 ...
228cd43 ...
955dff6 ...
...
留言
張貼留言