Oh-My-Zsh 操作 Git 的快捷键
本篇文章介紹 Oh-My-Zsh 安裝,以及 git 快捷鍵。也許你已經(jīng)煩透了每天?git add .?git commit -m 'some fix'?git push...
如果操作變成這樣?ga .?gcmsg 'some fix'?gp是不是很炫酷,好吧,對(duì)于已經(jīng)使用的人沒(méi)什么新鮮感。
接下來(lái)針對(duì)好奇的 Program development engineer(程序猿),做詳細(xì)介紹。
相信 git 大家并不陌生,不熟悉 git 操作的可以看我轉(zhuǎn)載的一篇阮一峰大神的?常用 Git 命令清單,重頭戲 oh-my-zsh 大家可以看?oh-my-zsh官網(wǎng)。
Oh-My-Zsh
Oh-My-Zsh is an open source, community-driven framework for managing your ZSH configuration. It comes bundled with a ton of helpful functions, helpers, plugins, themes, and a few things that make you shout...
簡(jiǎn)單說(shuō)就是集成插件的命令行工具。針對(duì) Mac 用戶(hù)和 Linux 用戶(hù)有很好的支持,windows 的朋友先不要急(有彩蛋)。
安裝
Mac 用戶(hù)和 Linux 用戶(hù)通過(guò)在您的終端中運(yùn)行以下命令之一來(lái)安裝。可以安裝通過(guò)?curl?或?wget?命令行。
via curl
sh?-c?"$(curl?-fsSL?https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"via wget
sh?-c?"$(wget?https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh?-O?-)"windows 我推薦一個(gè)集成 shell,git,oh-my-zsh 的命令行工具Babun。點(diǎn)擊進(jìn)入官網(wǎng)下載。當(dāng)然官網(wǎng)還給出了其他炫酷功能大家可以詳細(xì)閱讀。
oh-my-zsh 有許多插件和主題大家可以去?~/.zshrc?配置
更多功能可以去官網(wǎng)閱讀,這里強(qiáng)烈建議大家使用,因?yàn)闀?huì)提高工作效率,對(duì)于追求完美開(kāi)發(fā)體驗(yàn)的人幫助很大。
快捷鍵實(shí)現(xiàn)原理
這里只說(shuō) oh-my-zsh 針對(duì) git 的改進(jìn)。為什么支持縮寫(xiě)的形式。
大家可能知道 git 的快捷鍵 alias,它允許我們自己配制快捷鍵。例如
alias?gst='git?status'alias?gp='git?push'alias?gp='git?push'需要配置的快捷鍵過(guò)多,如果對(duì) git 操作了解不夠深入的人無(wú)法自行配置。那么 oh-my-zsh 是如何實(shí)現(xiàn)的呢?
其實(shí)就是用的?alias?,這里是 Github 上的鏈接?https://github.com/robbyrusse...?,通過(guò) url 便知這里的master分支下,plugins插件目錄,git插件下的配置文件。
喜歡閱讀代碼的直接點(diǎn)擊鏈接查看所有快捷鍵實(shí)現(xiàn)。這里便于整理把平時(shí)工作常用的快捷鍵給大家,至于不常用的大家查看 Github 上的鏈接,可能記得多了這種對(duì)應(yīng)關(guān)系容易弄混,建議大家只熟練記憶工作常有的快捷鍵,其它可以按著 git 官方文檔去做。減少出錯(cuò)和不必要的麻煩。
常用快捷鍵
g?-?git gst?-?git?status gl?-?git?pull gup?-?git?pull?--rebasegp?-?git?push gd?-?git?diff gdc?-?git?diff?--cachedgdv?-?git?diff?-w?"$@"?|?view gc?-?git?commit?-v gc!?-?git?commit?-v?--amendgca?-?git?commit?-v?-a gca!?-?git?commit?-v?-a?--amendgcmsg?-?git?commit?-m gco?-?git?checkout gcm?-?git?checkout?mastergr?-?git?remote grv?-?git?remote?-v grmv?-?git?remote?renamegrrm?-?git?remote?remove gsetr?-?git?remote?set-urlgrup?-?git?remote?updategrbi?-?git?rebase?-i grbc?-?git?rebase?--continuegrba?-?git?rebase?--abortgb?-?git?branch gba?-?git?branch?-a gcount?-?git?shortlog?-sn gcl?-?git?config?--listgcp?-?git?cherry-pick glg?-?git?log?--stat?--max-count=10glgg?-?git?log?--graph?--max-count=10glgga?-?git?log?--graph?--decorate?--allglo?-?git?log?--oneline?--decorate?--colorglog?-?git?log?--oneline?--decorate?--color?--graphgss?-?git?status?-s ga?-?git?addgm?-?git?mergegrh?-?git?reset?HEADgrhh?-?git?reset?HEAD?--hardgclean?-?git?reset?--hard?&&?git?clean?-dfxgwc?-?git?whatchanged?-p?--abbrev-commit?--pretty=mediumgsts?-?git?stash?show?--textgsta?-?git?stash gstp?-?git?stash?pop gstd?-?git?stash?dropggpull?-?git?pull?origin?$(current_branch) ggpur?-?git?pull?--rebase?origin?$(current_branch)ggpush?-?git?push?origin?$(current_branch) ggpnp?-?git?pull?origin?$(current_branch)?&&?git?push?origin?$(current_branch) glp?-?_git_log_prettily就我而言已經(jīng)足夠了,當(dāng)然也已經(jīng)包括了 Github 上大部分快捷鍵。
總結(jié)
好的開(kāi)發(fā)工具可以大大提升工作效率,應(yīng)用適當(dāng)即可,過(guò)多依賴(lài)快捷鍵自動(dòng)補(bǔ)全之類(lèi)的工具時(shí)間久了基礎(chǔ)知識(shí)退化,導(dǎo)致沒(méi)有好用的工具無(wú)法編程,建議新人熟記原始命令后再?lài)L試快捷鍵,避免錯(cuò)誤的發(fā)生(畢竟這是管理代碼工具,操作不當(dāng)很可能刪除了最近?add之前或者?commit?之前的代碼快照,因?yàn)槟承┎僮魇遣豢赡娴?#xff09;,親身踩過(guò)坑刪除了一天的工作,雖然重寫(xiě)兩個(gè)小時(shí)就完成,但十分不爽。
轉(zhuǎn)載于:https://blog.51cto.com/chenxiaolong/1966569
總結(jié)
以上是生活随笔為你收集整理的Oh-My-Zsh 操作 Git 的快捷键的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 专注服务,而非容器
- 下一篇: 错误:android.util.Supe