.bashrcにgitのショートカットコマンドをつくった

.bashrcにgitのショートカットコマンドをつくった

Read in: en
.bashrcにgitのショートカットコマンドをつくった

git add hogehoge, git commit hogehoge, git push hogehoge....

基本的なgitコマンドしか使わないのですが、毎回コマンド叩くの面倒くさい、楽したいということでエイリアスをつくってみました。

スクリプト

#git branch
alias git-b='git branch'

#git checkout
function gitCheckout() {
         stty erase ^H
         echo -n "What is the new branch name"?
         stty echo
         read var1
         git checkout ${var1}
}
alias git-c=gitCheckout

#git checkout -b
function gitCheckoutBranch() {
         stty erase ^H
         echo -n "What is the new branch name for checkout?"
         stty echo
         read var1
         git checkout -b ${var1}
}
alias git-c-b=gitCheckoutBranch

#git pull
function gitPull() {
        stty erase ^H
        echo -n "What is the remote repository name?"
        stty echo
        read var1
        git pull origin ${var1}
}
alias git-p=gitPull

#git set
function gitSet() {
      stty erase ^H
      echo -n "What file name do you add?"
      read var1
      git add ${var1}
      echo -n "What is the commit message?"
      read var2
      git commit -m\'${var2}\'
      echo -n "What is the branch name?"
      stty echo
      read var3
      git push origin ${var3}
}
alias git-set=gitSet

コマンド説明

トラブルシューティング

所感

追記

git configとかいうgit用のエイリアス設定コマンドがあったのを忘れていました。 よく使うgitコマンドのエイリアスを設定して開発効率をアップする

Tags: bash Git shellscript
Share: 𝕏 Post Facebook Hatena
✏️ View source / Discuss on GitHub
☕ サポート

このブログを応援していただける方は、以下からサポートをお願いします。いただいたサポートはブログ運営・技術研鑽に活用します。


関連記事