Skip to content

Instantly share code, notes, and snippets.

# pretty git log history
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset %an'
# add it to alias
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset %an'"
# now we can use <git-lg>
git lg
@xhlwill
xhlwill / Preferences.sublime-settings
Last active May 1, 2017 04:49
sublime text settings
{
"always_show_minimap_viewport": true,
// Goto Anything or Find in Files
"binary_file_patterns":
[
"*.jpg",
"*.jpeg",
"*.png",
"*.gif",
"*.ttf",
@xhlwill
xhlwill / react-native-project-error.log
Last active July 3, 2017 13:54
error log of react native project
Found Xcode project AwesomeProject.xcodeproj
Launching iPhone 6 (iOS 9.2)...
Building using "xcodebuild -project AwesomeProject.xcodeproj -scheme AwesomeProject -destination id=076CF12B-FDC4-448D-A592-F9158B9B8C28 -derivedDataPath build"
User defaults from command line:
IDEDerivedDataPathOverride = /Users/lovej/Documents/personal/projects/AwesomeProject/ios/build
=== BUILD TARGET RCTImage OF PROJECT RCTImage WITH CONFIGURATION Debug ===
@xhlwill
xhlwill / ppi.js
Last active April 28, 2017 07:49
calculate the PPI of screen
const ppi = function(height, width, inch) {
return Math.round(Math.sqrt(height*height + width*width) / inch);
}
@xhlwill
xhlwill / .bash_profile
Last active December 27, 2017 18:22
修改 .bash_profile(mac) 或 .bashrc(linux) 让 terminal 能自动补全 git 命令、显示 git 分支等信息 (git-completion.bash 和 git-prompt.sh 放入 ~ 目录)
source ~/git-completion.bash
source ~/git-prompt.sh
export GIT_PS1_SHOWDIRTYSTATE="true"
export GIT_PS1_SHOWSTASHSTATE="true"
export GIT_PS1_SHOWUNTRACKEDFILES="true"
export GIT_PS1_SHOWUPSTREAM="auto"
export GIT_PS1_SHOWCOLORHINTS="true"
green=$'\e[0;32m'
@xhlwill
xhlwill / count-git-commits.sh
Last active April 28, 2017 07:52
count total commits on current branch - 统计当前分支的提交数
git log | grep -e 'commit [a-zA-Z0-9]*' | wc -l
# 不准确,如果提交信息里有commit ...字样也会计算进去
# UPDATE:
git log --oneline | wc -l
# UPDATE 2:
# get the commit count for a revision (HEAD, master, a commit hash)
git rev-list --count <revision>
# get the commit count across all branches