LoginSignup
8
2

More than 5 years have passed since last update.

git cloneで役に立つエイリアス

Last updated at Posted at 2019-04-02

全世界のgitユーザー待望のエイリアス作りました。
GitリポジトリのURLをコピペしたと思ったらgit clone git cloneになってしまったときにもgit cloneできるようにするエイリアスです。

~/.alias
alias git='history 1|sed -r "s/ *[0-9]+ *//;s/^ *git *clone *git/git/"|sh #'

上記コマンドをエイリアスに登録するか、実行してください。
git_clone_alias.gif

間違ってgit clonegit cloneになっても大丈夫です。

他のコマンドには影響を与えないので、便利便利

動かした環境

  • Git bash for Windows
  • Ubuntu 18.04

のBashでは動きます。

Macでは試してないので誰か試していただけると幸いです。

追記

本気で使いたい人向け

git 自体をエイリアスにしているので、gitに他のエイリアス(例えばalias gs='git status')を登録していた場合は影響を与えます。
本当に使いたい場合は、gitコマンドを拡張すると幸せになれます。

# gitコマンドを拡張
$ echo 'git clone $(echo "$*"|sed -r "s/^ *git *clone//")' | sudo tee -a /usr/bin/git-get
$ sudo chmod +x /usr/bin/git-get

## 使うとき
$ git get https://github.com/amanoese/splash-julia
## or
$ git get git clone https://github.com/amanoese/splash-julia
8
2
0

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
8
2