$ ssh -v [email protected]
$ git config --global user.name "John Doe"
$ git config --global user.email [email protected]
設置默認使用的文本編輯器
$ git config --global core.editor emacs
差異分析工具,例如:
git config --global merge.tool vimdiff
檢查已有的配置信息
git config --list
$ git help
$ git --help
$ git help config
Create a new repository on the command line
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/LiuHaillong/t
git push -u origin master
Push an existing repository from the command line
<pre>
git remote add origin https://github.com/LiuHaillong/t
git push -u origin master
</pre>
初始化新倉庫
git init
$ git clone https://github.com/LiuHaillong/t
$ git clone https://github.com/LiuHaillong/t mygrit #項目重命名
查看文件當前處於什麼狀態,
git status
git add 開始跟蹤一個新文件
暫存這次更新,需要運行git add 命令(這是個多功能命令,根據目標文件的狀態不同,此命令的效果也不同:可以用它開始跟蹤新文件,或者把已跟蹤的文件放到暫存區,還能用於合併時把有衝突的文件標記爲已解決狀態等)
git diff查看尚未暫存的文件更新了哪些部分
git diff --cached 命令 已經暫存起來的文件和上次提交時的快照之間的差異
git diff --staged,Git 1.6.1 及更高版本還允許使用這個,效果是相同的,但更好記些
=====================
.gitignore 文件
# 此爲註釋 – 將被 Git 忽略
*.[oa] # 忽略所有以 .o 或 .a 結尾的文件
*~ # 忽略所有以波浪符(~)結尾的文件
*.a # 忽略所有 .a 結尾的文件
!lib.a # 但 lib.a 除外
/TODO # 僅僅忽略項目根目錄下的 TODO 文件,不包括 subdir/TODO
build/ # 忽略 build/ 目錄下的所有文件
doc/*.txt # 會忽略 doc/notes.txt 但不包括 doc/server/arch.txt
提交更新
提交命令(暫存起來git add的)
git commit
可以用 -m 參數後跟提交說明的方式,在一行命令中提交更新:
git commit -m "edit intro" #這樣提交前就不用git add了
跳過使用暫存區域
-a 選項,Git 就會自動把所有已經跟蹤過的文件暫存起來一併提交,從而跳過 git add 步驟:
git commit -a -m "edit intro"
推送數據到遠程倉庫
git push origin master
git remote show origin
git remote rename pb paul 重命名pb爲paul
git remote rm paul 移除遠端倉庫
列顯已有的標籤
git tag
git tag -l 'v1.4.2.*'
新建標籤
git tag -a v1.4 -m 'my version 1.4'
git show v1.4
簽署標籤
git tag -s v1.5 -m 'my signed 1.5 tag'
再運行 git show 會看到對應的 GPG 簽名也附在其內:
git show v1.5
(一) GIT BASE
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.