Permalink
Browse files

Add some more useful git aliases

- Set autosquash on
- Add a bunch of useful aliases for log output and diffing the index
  • Loading branch information...
1 parent f4a1a88 commit e84f9e3d081305b0d294b9349ba60ebf2e34d6e4 John Barker & Michael Chinigo committed with John Barker Aug 17, 2012
Showing with 42 additions and 34 deletions.
  1. +42 −34 recipes/git_config_global_defaults.rb
@@ -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
@@ -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.