由於我每天從幾臺長名稱的計算機克隆,因此我想創建一個git alias
命令。使用git alias'ed命令的參數進行字符串連接
而不是
$ git clone git://machine.with.name.i.always.mistype/with/same/dirs/here/REPO.git
我想用(例如別名klone
)
$ git klone REPO.git
我如何可以連接REPO.git
一個git alias
裏面長主機和缺省目錄幹?
由於我每天從幾臺長名稱的計算機克隆,因此我想創建一個git alias
命令。使用git alias'ed命令的參數進行字符串連接
而不是
$ git clone git://machine.with.name.i.always.mistype/with/same/dirs/here/REPO.git
我想用(例如別名klone
)
$ git klone REPO.git
我如何可以連接REPO.git
一個git alias
裏面長主機和缺省目錄幹?
[alias]
klone = !sh -c 'git clone git://machine.with.name.i.always.mistype/with/same/dirs/here/$1' -
應該這樣做。
如果您沒有致力於確切的語法,請使用shell別名或稱爲「git-klone」的函數。使用bash或其他SH衍生殼:
git-klone()
{
git clone git://machine.with.name.i.always.mistype/with/same/dirs/here/"[email protected]"
}
使用csh或tcsh:
alias git-klone 'git clone git://machine.with.name.i.always.mistype/with/same/dirs/here/\!*'
您也可以保存自己在你的Git的配置使用的建構鍵入網址的基本部分:
[url "<actual url base>"]
insteadOf = <other url base>
說,
[url "git://machine.with.name.i.always.mistype/with/same/dirs/here"]
insteadOf = THERE
那麼,我想,下面應該工作:
$ git clone THERE/REPO.git
不敢相信這是在我的眼前的手冊頁所有的時間。謝謝。 –