Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
snippets [2017/11/28 13:54]
ojdo [Convert pictures to lower resolution in subfolder]
snippets [2018/09/25 20:22] (current)
ojdo [Aliases]
Line 8: Line 8:
  
 ==== Bash ==== ==== Bash ====
-<​code>​mkdir export && magick mogrify -resize 3000x3000 -quality 80 -path export *.jpg</​code>​+<​code ​bash>mkdir export && magick mogrify -resize 3000x3000 -quality 80 -path export *.jpg</​code>​
  
 ==== PowerShell ==== ==== PowerShell ====
  
-<​code>​mkdir (get-item $PWD).Name; magick mogrify -resize 3000x3000 -quality 80 -path (get-item $PWD).Name *.jpg</​code>​+<​code ​bash>mkdir (get-item $PWD).Name; magick mogrify -resize 3000x3000 -quality 80 -path (get-item $PWD).Name *.jpg</​code>​
  
-===== Git aliases ​=====+===== Git config ​=====
  
-Heavy-branching-capable ''​lg''​ command. Not as commonly used ''​ls''​ short (no graph) and ''​ll''​ long (file stats) forms. ''​la''​ is nice in that it lists all aliases. I hardly remember ​the ''​d''​ and ''​dc''​ aliasessadly. But then, typing them out does not hurt too much.+First, ​the full configuration, then some comments by section: 
 + 
 +<code ini> 
 +[color] 
 + ui = auto
  
-<​code>​ 
 [alias] [alias]
-    ​lg = log --pretty=tformat:'​%C(auto)%h %C(dim ​white)%cd %Creset%<​(50,​trunc)%s %C(bold blue)%aN%Creset%C(auto)%w(0,​0,​7)%+d%Creset' --decorate --graph ​--abbrev-commit --date=short + al = "!git config -l | grep "​^alias"​ | cut -c 7-" 
-    ​ls ​= log --pretty=format:'​%C(auto)%h %s %C(bold blue)%aN%C(auto)%d%Creset'​ --decorate + bl = for-each-ref --format='​%(align:​50,​left)%(color:​bold green)%(refname:​short)%(color:​reset)%(end)%0a ​ %(color:dim green)%(objectname:​short)%(color:​reset) %(color:dim cyan)%(authordate:​short)%(color:​reset) %(color:​cyan)%(authorname)%(color:​reset) %(subject)%0a'​ --sort=-authordate refs/​heads/​ 
-    ​ll ​= log --pretty=format:'​%C(auto)%h %C(dim ​white)%cd %Creset%s %C(bold blue)%aN%C(auto)%w(0,0,7)%+d%Creset'​ --decorate --name-status + ce = config --global --edit 
-    d diff + d = diff 
-    ​dc ​diff --cached + dc = diff --cached 
-    la = "!git config ​-l | grep "​^alias" | cut -c 7-"+ lg = log --pretty=tformat:'​%C(dim white)%m%C(dim green)%h %C(dim ​cyan)%cd %C(reset)%<​(50,​trunc)%s %C(cyan)%aN%C(reset)%C(auto)%w(0,​0,​8)%+d%C(reset)' --decorate --graph 
 + ll = log --pretty=format:'​%C(dim white)%m%C(dim green)%h %C(dim cyan)%cd %C(reset)%s %C(cyan)%aN%C(auto)%w(0,0,8)%+d%Creset'​ --decorate ​--name-status 
 + ls = log --pretty=format:'​%C(dim white)%m%C(dim green)%h %C(dim ​cyan)%cd %C(reset)%s %C(cyan)%aN%C(auto)%d%Creset'​ --decorate --date=short 
 + nl "​!author_names() { git log --pretty=format:'​%aN'​ -- "${@-.}" | sort | uniq -c | sort -n -r; }; author_names" 
 + 
 +[merge] 
 + tool = vimdiff 
 + 
 +[log] 
 + date = format:​%Y-%m-%d %H:%M 
 + graphColors = 20,​120,​220,​21,​121 
 + 
 +[push] 
 + default = simple 
 + 
 +[core] 
 + editor = vim
 </​code>​ </​code>​
 +
 +==== Aliases ====
 +
 +My main workhorse in day-to-day work is the ''​lg''​ (log graph) command, allowing for a quick overview on latest changes with ''​git lg %%--%%all''​ after a fetch. In case I want briefer output for a linear slice of commits, I use ''​ls''​ short (no graph). If I want to additionally see the changed files, ''​ll''​ (log long) can be used. Meta-alias ''​al''​ (alias list) does exactly that. 
 +
 +Saying ''​git dc''​ instead of ''​git diff %%--%%cached''​ for a commit preview is very nice. I hardly remember the ''​git d''​ instead of ''​git diff'',​ though. But then, typing that out does not hurt too much. Newcomer: ''​bl''​ (branch list) lists all local branches, together with its latest commit. It's designed to look similar to the output of ''​lg''​. I might extend it to output remotes in red; it already can list them by calling ''​git bl refs/​remotes''​.
 +
 +The ''​nl''​ (name list) lists all commit authors for the current state (HEAD). The optional argument allows to specify a directory or file, by default it operates on the current working directory (''​.''​). Quite useful to quickly determine the contributors for a particular component.
 +
 +See chapter [[https://​git-scm.com/​book/​en/​v2/​Git-Basics-Git-Aliases|2.7 Git Basics - Git Aliases]] from the Git Book for other generally useful aliases. I kind of like ''​unstage'',​ but have already embraced the concept behind ''​reset HEAD'',​ so I am too late for that alias.
 +
 +
 +==== vim ====
 +
 +It's easier on the (ok, //my//) brain to switch from tool to tool without having to transfer from CLI to GUI window. But that's just opinion.
 +
 +==== log ====
 +
 +My preferred ISO-inspired default date format, but without the unneeded precision of seconds. Date and time are split by a space, not the standard ''​T''​ which makes ''​20010214T2359''​ easier to parse, but harder to read. The graphColors allow to specify which of the (typically) 256 terminal colours are used to differentiate between different branches. Here I recommend using much more than the (randomly) chosen 5 values I have shown here.
 +
 +
  
  • snippets.1511877291.txt.gz
  • Last modified: 2017/11/28 13:54
  • by ojdo