Skip to content
This repository has been archived by the owner on Mar 24, 2022. It is now read-only.

Commit

Permalink
Add some more useful git aliases
Browse files Browse the repository at this point in the history
- Set autosquash on
- Add a bunch of useful aliases for log output and diffing the index
  • Loading branch information
John Barker & Michael Chinigo authored and John Barker committed Mar 19, 2013
1 parent f4a1a88 commit e84f9e3
Showing 1 changed file with 42 additions and 34 deletions.
76 changes: 42 additions & 34 deletions recipes/git_config_global_defaults.rb
Expand Up @@ -4,50 +4,53 @@
template "#{WS_HOME}/.gitignore_global" do
source "gitignore_global.erb"
owner WS_USER
variables(
:ignore_idea => node[:git_global_ignore_idea]
)
variables(:ignore_idea => node[:git_global_ignore_idea])
end

execute "set global git ignore" do
command "git config --global core.excludesfile #{WS_HOME}/.gitignore_global"
user WS_USER
not_if "git config --global core.excludesfile | grep -q .gitignore_global"
not_if "[ -z `git config --global core.excludesfile`]"
end

execute "set alias st=status" do
command "git config --global alias.st status"
execute "make the pager prettier" do
# When paging to less:
# * -x2 Tabs appear as two spaces
# * -S Chop long lines
# * -F Don't require interaction if paging less than a full screen
# * -X No scren clearing
# * -R Raw, i.e. don't escape the control characters that produce colored output
command %{git config --global core.pager "less -FXRS -x2"}
user WS_USER
end

execute "set alias di=diff" do
command "git config --global alias.di diff"
user WS_USER
end

execute "set alias co=checkout" do
command "git config --global alias.co checkout"
user WS_USER
end

execute "set alias ci=commit" do
command "git config --global alias.ci commit"
user WS_USER
end

execute "set alias br=branch" do
command "git config --global alias.br branch"
user WS_USER
end

execute "set alias sta=stash" do
command "git config --global alias.sta stash"
user WS_USER
end

execute "set alias llog=log --date=local" do
command "git config --replace-all --global alias.llog 'log --date=local'"
user WS_USER
aliases =<<EOF
st status
di diff
co checkout
ci commit
br branch
sta stash
llog \"log --date=local\"
flog \"log --pretty=fuller --decorate\"
lg \"log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative\"
lol \"log --graph --decorate --oneline\"
lola \"log --graph --decorate --oneline --all\"
blog \"log origin/master... --left-right\"
ds \"diff --staged\"
fixup \"commit --fixup\"
squash \"commit --squash\"
unstage \"reset HEAD\"
rum rebase master@{u}
EOF

aliases.split("\n").each do |alias_string|
abbrev = alias_string.split[0]
execute "set alias #{abbrev}" do
command "git config --global alias.#{alias_string}"
user WS_USER
only_if "[ -z `git config --global alias.#{abbrev}` ]"
end
end

execute "set apply whitespace=nowarn" do
Expand Down Expand Up @@ -84,3 +87,8 @@
command "git config --global branch.autosetupmerge true"
user WS_USER
end

execute "set rebase autosquash=true" do
command "git config --global rebase.autosquash true"
user WS_USER
end

0 comments on commit e84f9e3

Please sign in to comment.