git的使用方法,如何配置

使用 git自從 git-1.5.4 , 'git-xyz' 這種用法就不提倡了,而推薦 'git xyz' 風格。  git 的後續版本中將在 make install時不再安裝 'git-xyz' 這些 hardlinks 。當如果執行 git --exec-path 輸出的目錄中依然有 git-xyz 這些腳本,你還是可以把這個路徑加到 PATH 環境變量中,這樣還能夠使用 git-xyz 形式的腳本。config   ------    我的一些簡單的配置:    $ git-config user.name "Jike Song"   $ git-config user.email [email][email protected][/email]   $ git-config core.editor vim   $ git-config core.pager "less -N"   $ git-config color.diff true  // 顯示 diff 時色彩高亮   $ git-config alias.co checkout  // 給 git checkout 取個別名,這樣只輸入 git co 即可   $ git-config sendemail.smtpserver /usr/bin/msmtp     注意,這會在當前 repository 目錄下的 .git/config 中寫入配置信息。   如果 git-config 加了 --global    選項,配置信息就會寫入到 ~/.gitconfig 文件中。   因爲你可能用不同的身份參與不同的項目,而多個    項目都用 git 管理,所以建議不用 --global 配置。   $ git-val -l  // 列出 git 變量     init   ----    $ git-init-db  // 創建一個 .git/ 目錄,初始化一個空的 git 倉庫//這個目錄在git-clone時也會創建。也就是說clone時會自動初始化git//倉庫裏需要的東西    clone   -----    $ git-clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git [dir name]   [dir name] 是你想讓這個倉庫叫什麼名字。   如果不指定,就會等同於目標倉庫的名字。     注意,這種 git server 形式的 repository ,都有一個 filename.git 文件;   而對於 *.git 的操作,也可以    針對 .git 所在的目錄: $  mkdir tmp/$  cd tmp/$  git-clone ~/Sources/linux-2.6     或者通過 ssh : $  git-clone [email][email protected][/email]:/home/arc/Sources/linux-2.6     此時當前目錄下有一個 .git/ 目錄 .  以下我們都在 linux-2.6/ 下演示:  使用 git自從 git-1.5.4 , 'git-xyz' 這種用法就不提倡了,而推薦 'git xyz' 風格。  git 的後續版本中將在 make install時不再安裝 'git-xyz' 這些 hardlinks 。當如果執行 git --exec-path 輸出的目錄中依然有 git-xyz 這些腳本,你還是可以把這個路徑加到 PATH 環境變量中,這樣還能夠使用 git-xyz 形式的腳本。config   ------    我的一些簡單的配置:    $ git-config user.name "Jike Song"   $ git-config user.email [email][email protected][/email]   $ git-config core.editor vim   $ git-config core.pager "less -N"   $ git-config color.diff true  // 顯示 diff 時色彩高亮   $ git-config alias.co checkout  // 給 git checkout 取個別名,這樣只輸入 git co 即可   $ git-config sendemail.smtpserver /usr/bin/msmtp     注意,這會在當前 repository 目錄下的 .git/config 中寫入配置信息。   如果 git-config 加了 --global    選項,配置信息就會寫入到 ~/.gitconfig 文件中。   因爲你可能用不同的身份參與不同的項目,而多個    項目都用 git 管理,所以建議不用 --global 配置。   $ git-val -l  // 列出 git 變量     init   ----    $ git-init-db  // 創建一個 .git/ 目錄,初始化一個空的 git 倉庫//這個目錄在git-clone時也會創建。也就是說clone時會自動初始化git//倉庫裏需要的東西    clone   -----    $ git-clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git [dir name]   [dir name] 是你想讓這個倉庫叫什麼名字。   如果不指定,就會等同於目標倉庫的名字。     注意,這種 git server 形式的 repository ,都有一個 filename.git 文件;   而對於 *.git 的操作,也可以    針對 .git 所在的目錄: $  mkdir tmp/$  cd tmp/$  git-clone ~/Sources/linux-2.6     或者通過 ssh : $  git-clone [email][email protected][/email]:/home/arc/Sources/linux-2.6     此時當前目錄下有一個 .git/ 目錄 .  以下我們都在 linux-2.6/ 下演示:    pull   ----   $ git-pull  // 更新本地的 git tree 。   如果自從你 clone 了 linus tree 之後, linus tree//有新的改動,那麼把這些更改更新到你的本地tree中//類似於cvs  update  pull   ---- FYI:  git-clone 和 git-pull 都會默認調用 git-merge 。   FYI:  每天 git-pull 更新技巧:1)  git-describe ,例如目前是 v2.6.26-rc8-122)  git-pull -v3)  git-describe ,例如是 v2.6.26-rc8-224)  git-log -p -10 查看變化    diff   ----   $ git-diff  /* 列出自己本地的 tree 中已修改、但卻未 commit 的改動   這也是產生 patch 的方式 ( 用來提交的 patch 需要先 commit 到自己的 tree 裏,   然後 git-format-patch) 。   注意,使用 git-diff 產生的 patch 都應該在  patch(1) 時指定 -p1 ,或者直接使用 git-apply 打補丁 */    選項:     --color  diff 語法高亮 ( 可以 git-config color.diff true)     --ignore-space-at-eol   忽略行尾的 whitespace     -b     --ignore-space-change   忽略行尾的 whitespace ,並且認爲所有的 whitespace 都是一樣的     -w     --ignore-all-space  比較兩行的時候,完全忽略 whitespace 。這樣,即使是一行有很多      whitespaces ,另一行文字一樣但是沒有 whitespace , git 也認爲這兩行內容一致。   $ git-pull  // 更新本地的 git tree 。   如果自從你 clone 了 linus tree 之後, linus tree//有新的改動,那麼把這些更改更新到你的本地tree中//類似於cvs  update  Internet上有很多免費的git  hosting sites ,你可以把自己的項目放在上邊,以便和別人協同開發。  git 官方站點有一個頁面列出了常用的站點: http://git.or.cz/gitwiki/GitHosting 其中最老的site是: http://repo.or.cz 該站點要求項目必須是*free  software* 。 另一個現在最受歡迎(沒用過,看別人的評論)的是: http://github.com/ GITHUB把projects分爲3種:  a) opensource projects ,免費;  b) personal projects ,收費;  c) business projects ,當然收費:) 
發佈了4 篇原創文章 · 獲贊 0 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章