summaryrefslogtreecommitdiffstats
path: root/git/config
blob: 339ebe7fbbcf8a6663671905821ad7792e74e018 (plain)
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
[alias]
	l = log --color --graph --format=format:'%C(blue)%h%C(reset) - %C(white)(%ar)%C(reset) %s %C(red)%d%C(reset) %C(bold blue)— %an%C(reset)' --abbrev-commit
	lg = log --color --graph -n 15 --format=format:'%C(blue)%h%C(reset) - %C(white)(%ar)%C(reset) %s %C(red)%d%C(reset) %C(bold blue)— %an%C(reset)' --abbrev-commit
	lf = log --color --graph --name-status --format=format:'%C(blue)%h%C(reset) - %C(white)(%ar)%C(reset) %s %C(red)%d%C(reset) %C(bold blue)— %an%C(reset)' --abbrev-commit
	ll = log --color --graph --all --format=format:'%C(blue)%h%C(reset) - %C(white)(%ar)%C(reset) %s %C(red)%d%C(reset) %C(bold blue)— %an%C(reset)' --abbrev-commit

	s = status -s
	ss = status
	a = add
	ai = add -i
	p = push
	pu = pull
	f = fetch
	fa = fetch --all
	c = commit
	dt = difftool
	dtg = difftool -g
	b = branch
	bv = branch -v
	bva = branch -va
	co = checkout
	cb = checkout -b
	d = diff --stat
	dd = diff
	m = merge --no-ff
	r = remote
	rv = remote -v
	rb = rebase
	rbi = rebase -i
	fap = fetch --all -p -t
	stash-all = stash save --include-untracked

	# List every branch, local and remote, in order of most recent to oldest commit, showing the branch's last commit and some last commit meta-data
	br = for-each-ref --sort=-committerdate refs/heads/ refs/remotes/origin/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))' -

	# ff [<args>]
	# if no <args> are given, tries to fast-forward with the upstream branch
	ff = !"perl -MGit -E' \
		push @ARGV, Git::command_oneline(qw/rev-parse --abbrev-ref --symbolic-full-name @{u}/) unless @ARGV; \
		Git::command_noisy(qw{merge --ff-only}, @ARGV); \
		'"
	# ff = merge --ff-only

	# tomerge <branch> <regex> tells you which branches matching <regex> have not been merged into <branch> yet
	# <branch> defaults to HEAD
	# <regex> defaults to .
	tomerge = !"perl -MGit -E' \
		my ($br, $rx) = (shift // q{HEAD}, shift // qr{.}); \
		say for grep { \
			/$rx/ && !/\\b(master|maint|next)/; \
		} Git::command(qw{branch -r --no-merged}, $br); \
		'"

	# topics <regex>
	# show topics (branches) matching the ai/description format or <regex>
	topics = !"perl -MGit -MList::Util=uniq -E' \
		my $rx = shift // qr{[a-z]{1,3}/.}; \
		say for uniq map { \
			$_ = (split /\\s/)[2]; \
			s!(remotes|origin)/!!g; \
			/$rx/ && !/HEAD/ ? $_ : () \
		} Git::command(qw/branch --sort=committerdate -r/) \
		'"