跳到主要内容

2 篇博文 含有标签「git」

查看所有标签

git使用技巧汇总

· 阅读需 1 分钟
Danny He
Developer in ChengDu,China

别名:更方便的使用命令

配置git使用别名

git config --global alias.st status
git config --global alias.co checkout
git config --global alias.ci commit
git config --global alias.br branch
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

如何计算git变动的文件大小

· 阅读需 1 分钟
#!/bin/bash
# The tool to get the total size of autoupdate
# by Dannyhe

function NotSupport()
{
echo "Not support $OSTYPE"
exit -1
}

function main()
{
echo "os: $OSTYPE"
echo "size:"
if [[ "$OSTYPE" == "linux-gnu" ]]; then
NotSupport
elif [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX
git log --name-status -1 | grep -E '^[A-Z]\b' | sort -k 2,2 -u | grep -E "M|A" | awk '{print $2}' | xargs stat -f "%z" | awk '{t+=$0}END{print t/(1024*1024)" Mb"}'
elif [[ "$OSTYPE" == "cygwin" ]]; then
# POSIX compatibility layer and Linux environment emulation for WindowsNotSupport
NotSupport
elif [[ "$OSTYPE" == "msys" ]]; then
# Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
git log --name-status -1 | grep -E '^[A-Z]\b' | sort -k 2,2 -u | grep -E "M|A" | awk '{print $2}' | xargs du -b | awk '{t+=$0}END{print t/(1024*1024)" Mb"}'
elif [[ "$OSTYPE" == "freebsd"* ]]; then
NotSupport
else
NotSupport
fi
}

main