在本地安装git的HTML帮助文档
當我們想查詢git某條指令如何使用時,git官網有詳盡的文檔供我們查看。在命令行下我們也可以隨時通過 git –help的方法查看某條命令的詳細幫助。
相對于在Terminal中內置的幫助文檔,HTML格式更清晰,更詳盡。
但是如果我想在無法上網的情況下也能查看git官網的詳盡的幫助文檔,有沒有辦法那?當然有了,下面就教大家如何在本機搭建git的HTML幫助文檔。
在Windows上設置很簡單,主需要安裝Msysgit,就會自動為你設置起本地的HTML幫助文檔。所以這篇文章主要講在Mac和Linux下該如何實現。
一,運行git help –-web commit查看git默認的保存html文件的路徑。
| 1 2 3 4 5 | $ git help --web commit #Attempt to open the html help for the commit command #fatal: '/usr/local/git/share/doc/git-doc': not a documentationdirectory. |
我們得到了git默認的存放html文件的路徑是/usr/local/git/share/doc/git-doc。當然你得到的路徑有可能和這個不一樣。
二,切換到這個路徑下,遷出存放在git repo中的html文件。
| 1 2 3 4 | $ sudo mkdir -p /usr/local/git/share/doc # Create the path for the docs to be installed to cd #/usr/local/git/share/doc $ sudo git clone git://git.kernel.org/pub/scm/git/git-htmldocs.git git-doc # Clone the git repo and check out the html documents branch |
三,運行 vim ~/.gitconfig 命令,在.gitconfig文件中加入如下配置。
| 1 2 3 4 5 6 7 | [help] format = web [web] browser = open |
當然也可以使用其他的編輯器來編輯.gitconfig文件。
只要這三步就設置起了本地的HTML幫助文檔。你可以再次運行git help -–web commit,就可以查看在瀏覽器中自動打開的HTML幫助說明頁面了。
如果git的幫助文檔更新了,如何同步到本地那?很簡單,運行git pull命令就行。
| 1 2 | $ cd /usr/local/git/share/doc/git-doc $ sudo git pull |
如何查看這些幫助文檔那?更簡單了,例如:
| 1 | $ git remote --help |
就會自動在瀏覽器中打開針對remote的幫助文檔。
from:?http://www.huangbowen.net/blog/2012/08/08/zai-ben-di-an-zhuang-gitde-htmlbang-zhu-wen-dang/
總結
以上是生活随笔為你收集整理的在本地安装git的HTML帮助文档的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 在ThoughtWorks工作两个多月的
- 下一篇: 《卓有成效的程序员》----读书笔记一