git 设置别名 git alias

git config --global alias.st status
git config --global alias.ck checkout
git config --global alias.br branch
git config --global alias.cf config
git config --global alias.fc fetch

git config --replace-all --global alias.brv "branch --v"
git config --replace-all --global alias.geturl "config --get remote.origin.url"

参考https://git-scm.com/book/en/v2/Git-Basics-Git-Aliase

有了这些就方便很多了。遇到可以自己再写。

或者直接复制到.gitconfig

[alias]
	ch = checkou
	st = status
	staust = 'gitst'
	cf = config
	ck = checkout
	ft = fetch
	fh = fetch
	br = branch
	brv = branch --v
	geturl = config --get remote.origin.url
	bs = bisect
	lg = log

常见配置:

[user]
	name = caoxinyu
	email = 1455971532@qq.com
[merge]
   tool = studio64
[mergetool "studio64"]
   cmd = studio64.exe merge $(cd $(dirname "$LOCAL") && pwd)/$(basename "$LOCAL") $(cd $(dirname "$REMOTE") && pwd)/$(basename "$REMOTE") $(cd $(dirname "$BASE") && pwd)/$(basename "$BASE") $(cd $(dirname "$MERGED") && pwd)/$(basename "$MERGED")
   trustExitCode = true
   keepbackup = false
[diff]
   tool = studio64
[difftool "studio64"]
   cmd = studio64.exe diff $(cd $(dirname "$LOCAL") && pwd)/$(basename "$LOCAL") $(cd $(dirname "$REMOTE") && pwd)/$(basename "$REMOTE")
   trustExitCode = true
   keepbackup = false
[alias]
	ch = checkou
	st = status
	staust = 'gitst'
	cf = config
	ck = checkout
	ft = fetch
	fh = fetch
	br = branch
	brv = branch --v
	geturl = config --get remote.origin.url
	bs = bisect
	lg = log
	cfg = config --global
	cfga = config --global alias.
	pull = pl
	pl = pull
	cm = commit -c HEAD
	ps = push
	lsr = ls-remote --heads
	udc = reset HEAD~
	ftg = fetch --tags
	am = commit -amend
	cmd = commit --amend
	rsh = reset HEAD~
	cmi = commit --interactive -c HEAD --reset-author
	i = --interactive
	rss = reset --soft
	rmc = rm --cached
	cp = cherry-pick
	cpx = cherry-pick -x
	bl = blame
	gk = gitk
	ltn = ls-tree -r HEAD~ --name-only
	lt = ls-tree -r HEAD~ --name-only
	ltng = ls-tree -r HEAD~ --name-only |grep
	lgd = log -p --full-diff
[i18n]
	commitencoding = utf-8
	logoutputencoding = utf-8
[core]
	quotepath = false
[gui]
	encoding = utf-8
[i18n "commit"]
	encoding = utf-8
[http]
[credential]
	helper = manager

原文地址:https://www.cnblogs.com/caoxinyu/p/10568541.html