TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Everyday Git Aliases

6 pointsby joejagabout 12 years ago

3 comments

Flenserabout 12 years ago
git staged<p>alias for<p><pre><code> git log remotes/trunk~4..HEAD --pretty=format:"%C(yellow)%h%C(white) %ad %aN%x09%d%x09%s" --date=short | awk -F'\t' '{gsub(/[, ]/,"",$2);gsub(/HEAD/, "\033[1;36mH\033[00m",$2);gsub(/master/, "\033[1;32mm\033[00m",$2);gsub(/trunk/, "\033[1;31mt\033[00m",$2);print $1 "\t" gensub(/([\(\)])/, "\033[0;33m\\1\033[00m","g",$2) $3}' | less -eiFRXS </code></pre> Shows condensed log of unpushed changes with colours and truncates HEAD/master/remote to initial letter.<p>Add to config with:<p><pre><code> git config alias.staged '!git log remotes/trunk~4..HEAD --date=short --pretty=format:"%C(yellow)%h%C(white) %ad %aN%x09%d%x09%s" | awk -F"\t" "{gsub(/[, ]/,\"\",\$2);gsub(/HEAD/, \"\033[1;36mH\033[00m\",\$2);gsub(/master/, \"\033[1;32mm\033[00m\",\$2);gsub(/trunk/, \"\033[1;31mt\033[00m\",\$2);print \$1 \"\t\" gensub(/([\(\)])/, \"\033[0;33m\\\\\1\033[00m\",\"g\",\$2) \$3}"' </code></pre> Although I've changed it a bit since I worked out the above. Here's what I currently have in my config file:<p><pre><code> staged = "!sh -c 'git log ${1-remotes/trunk~4..HEAD} --pretty=format:\"%C(yellow)%h%C(white) %ad %aN%x09%d%x09%s\" --date=short $2 | awk -F\"\\t\" \"{gsub(/[, ]/,\\\"\\\",\\$2);gsub(/HEAD/, \\\"\\033[1;36mH\\033[00m\\\",\\$2);gsub(/master/, \\\"\\033[1;32mm\\033[00m\\\",\\$2);gsub(/trunk/, \\\"\\033[1;31mt\\033[00m\\\",\\$2);gsub(/$USERNAME/,\\\"\\033[0;33m$USERNAME\\033[00m\\\",\\$1);print \\$1 \\\"\\t\\\" gensub(/([\\(\\)])/, \\\"\\033[0;33m\\\\\\\\\\1\\033[00m\\\",\\\"g\\\",\\$2) \\$3}\" | less -eiFRX' -"</code></pre>
joejagabout 12 years ago
I'd love to hear what aliases other people use in their workflow
joshguthrieabout 12 years ago
whoiswinning<p><pre><code> $ alias whoiswinning whoiswinning='git shortlog -s -n' $</code></pre>