LoginSignup
3
4

More than 5 years have passed since last update.

【簡単設定】【初心者向け】git関連でタイポする人に見て欲しいaliasの設定

Last updated at Posted at 2015-06-25

メリット

  • git pullやらgit checkoutやらで発生するタイポ数削減(めちゃくちゃタイポするので。。。)

  • git周りの手間を効率化出来る(単純にタイプ数減る)

  • 自動化の設定までは出来ない人でも導入出来る(小さな一歩から始めたい)

  • 特別なシェルを入れる必要なし

デメリット

  • 慣れるまで大変

環境

  • Mac 10.9.5
  • shell bash

手順

1.ターミナルを開いてvi ~/.bash_profileを実行し、開いた「bash_profile」に以下をコピペ


# ----------------------
# Git Aliases
# ----------------------
alias ga='git add'
alias gaa='git add .'
alias gaaa='git add -A'
alias gb='git branch'
alias gbd='git branch -d '
alias gc='git commit'
alias gcm='git commit -m'
alias gco='git checkout'
alias gcob='git checkout -b'
alias gcom='git checkout master'
alias gd='git diff'
alias gda='git diff HEAD'
alias gi='git init'
alias gl='git log'
alias glg='git log --graph --oneline --decorate --all'
alias gld='git log --pretty=format:"%h %ad %s" --date=short --all'
alias gm='git merge --no-ff'
alias gp='git pull origin'
alias gpo='git push origin'
alias gss='git status -s'
alias gst='git stash'
alias gstl='git stash list'
alias gstp='git stash pop'
alias gstd='git stash drop'

# ----------------------
# Git Function
# ----------------------
# Git log find by commit message
function glf() { git log --all --grep="$1"; }

*基本的に外部リポジトリはoriginのためpushやpullは
originを指定。
適宜、変更する必要がある方はorigin部分を外すことをオススメします。

2.設定反映のためターミナルを再起動

最近、gitを始めた人向けなので以降は自分流にカスタマイズしていくことでより効率化出来ると思います。

3
4
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4