我很好奇,想知道是否可以在Git的製作別名,即元別名創建一個別名,以便不用打字git config --global alias.
-whatever一個能只要寫git alias
- 無論如何。
背景:
我只升溫到Bash和Git的,並且最近已經開始創建別名像
git cfg
爲git config --global
和,from this page,git hist
爲:git log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short
最後一個例子通過鍵入:
git config --global alias.hist 'log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short'
隨着我
git cfg
別名我可以縮短,爲:git cfg alias.hist 'log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short'
但我想弄清楚,如果我能縮短它更進一步使git cfg alias.
只是git alias
,部分出方便,部分出於好奇,部分原因是想了解更多關於Git和Bash的內容。
嘗試的解決方案?:
我發現我可以打電話
git $(echo 'cfg')
,並得到相同的結果git cfg
。希望我能像鍵入一些git alias st status
創建一個快捷別名git st
爲git status
git cfg alias.alias '$(echo "config --global alias.")'
:
所以,我想通過輸入此創建別名爲
alias
。不幸的是,這似乎並沒有在這一點上的Git不再承認
$(echo
的命令,因爲工作,即使它的工作別名的背景之外,與git $(echo 'cfg')
。我也不確定是否工作,因爲示例中的st
必須從執行的回顯中直接附加到alias.
。
有沒有人有任何建議,如何使這成爲可能?
這不僅工作,但解釋也有幫助:-)謝謝! – guypursey 2013-05-06 09:26:45