profile-git 857 B

12345678910111213141516171819202122232425262728293031
  1. git-ignore() {
  2. local site="https://raw.githubusercontent.com/github/gitignore/master"
  3. if [[ $1 == "--global" ]]; then
  4. shift
  5. ignore_file=${HOME}/.gitignore_global
  6. site+="/Global"
  7. else
  8. ignore_file="./.gitignore"
  9. fi
  10. wget -qO- "${site}/${1}.gitignore" >> "${ignore_file}"
  11. }
  12. git-create() {
  13. mkcd "${1}"; shift
  14. git init
  15. touch .gitignore
  16. local message="Initializing repository"
  17. if [[ $# -ge 1 ]]; then
  18. for i in "$@"; do git-ignore "${i}"; done
  19. message+=" with ignore lists: [ $1"
  20. [[ $# -eq 1 ]] || message+="$(printf ", %s" "${@:2}")"
  21. message+=" ]"
  22. fi
  23. maybe_do git-ignore-local
  24. git add .gitignore
  25. git commit -m "${message}"
  26. }
  27. alias git-graph="git log --graph --pretty=oneline --abbrev-commit --decorate --all"
  28. alias git-cleanup='git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d'