git-ignore() { local site="https://raw.githubusercontent.com/github/gitignore/master" if [[ $1 == "--global" ]]; then shift ignore_file=${HOME}/.gitignore_global site+="/Global" else ignore_file="./.gitignore" fi wget -qO- "${site}/${1}.gitignore" >> "${ignore_file}" } git-create() { mkcd "${1}"; shift git init touch .gitignore local message="Initializing repository" if [[ $# -ge 1 ]]; then for i in "$@"; do git-ignore "${i}"; done message+=" with ignore lists: [ $1" [[ $# -eq 1 ]] || message+="$(printf ", %s" "${@:2}")" message+=" ]" fi maybe_do git-ignore-local git add .gitignore git commit -m "${message}" } git-sync-release() { rel="release/${1}" br="$(git branch | grep '^\*' | cut -c3-)" # Confirm that this is a real branch (git branch -r | grep "${rel}" &>/dev/null) || return 1 # Merge dev # Make sure that we're not doing a weird clobber git checkout "${rel}" || return 2 # Sanity check... git pull git merge --ff-only origin/dev || return 3 # Update origin:release git push git checkout "${br}" # Don't delete if we're on this branch [[ "${br}" == "${rel}" ]] || git branch -D "${rel}" } alias git-graph="git log --graph --pretty=oneline --abbrev-commit --decorate --all" alias git-history-graph="git log --graph --pretty='format:%C(auto)%h (%<(50,trunc)%s, %ad)%d' --abbrev-commit --decorate --all" git-weeks-ago() { weeks="${1:-1}" end="$(date +"%Y-%m-%d" --date="${weeks} weeks ago Sunday")" begin="$(date +"%Y-%m-%d" --date="$((weeks+1)) weeks ago Sunday")" echo "--after ${begin} --before ${end}" } alias git-cleanup='(git branch --merged | egrep -v "(^\*|^\+|master|dev)" | xargs git branch -d); (git fetch --prune 2>&1 | grep deleted | sed "s/.*-> origin\///" | xargs git branch -D)'