建立
複製乙個已建立的倉庫:
建立乙個新的本地倉庫:$ git clone ssh
:
$ git init
本地修改
顯示工作路徑下已修改的檔案:
$ git status
顯示與上次提交版本檔案的不同:
$ git diff
把當前所有修改新增到下次提交中:
$ git add
把對某個檔案的修改新增到下次提交中:
提交本地的所有修改:$ git add -p
提交之前已標記的變化:$ git commit
-a
$ git commit
附加訊息提交:
提交,並將提交時間設定為之前的某個日期:$ git commit -m
'message here'
修改上次提交git commit
--date
="`date --date='n day ago'`"
-am
"commit message"
請勿修改已發布的提交記錄!
把當前分支中未提交的修改移動到其他分支$ git commit
--amend
搜尋git stash
git checkout branch2
git stash pop
從當前目錄的所有檔案中查詢文字內容:
在某一版本中搜尋文字:$ git grep
"hello"
提交歷史$ git grep
"hello"v2.
5
從最新提交開始,顯示所有的提交記錄(顯示hash, 作者資訊,提交的標題和時間):
$ git log
顯示所有提交(僅顯示提交的hash和message):
顯示某個使用者的所有提交:$ git log
--oneline
顯示某個檔案的所有修改:$ git log
--author
="username"
誰,在什麼時間,修改了檔案的什麼內容:$ git log -p
分支與標籤$ git blame
列出所有的分支:
$ git branch
切換分支:
建立並切換到新分支:$ git checkout
基於當前分支建立新分支:$ git checkout -b
基於遠端分支建立新的可追溯的分支:$ git branch
<
new-
branch
>
刪除本地分支:$ git branch
--track
<
new-
branch
>
<
remote
-branch
>
給當前版本打標籤:$ git branch -d
更新與發布$ git tag
<
tag-
name
>
列出當前配置的遠端端:
顯示遠端端的資訊:$ git remote
-v
新增新的遠端端:$ git remote show
$ git remote add
$ git fetch
將遠端端版本合併到本地版本中:$ git remote pull
$ git pull origin master
將本地版本發布到遠端端:
刪除遠端端分支:$ git push remote
發布標籤:$ git push
:<
branch
>
(since
gitv1
.5.0)or
git push
--delete
(since
gitv1
.7.0
)
$ git push
--#br
合併與重置(資質代辦)
將分支合併到當前head中:
將當前head版本重置到分支中:$ git merge
請勿重置已發布的提交!
退出重置:$ git rebase
解決衝突後繼續重置:$ git rebase
--abort
使用配置好的merge tool 解決衝突:$ git rebase
--continue
$ git mergetool
在編輯器中手動解決衝突後,標記檔案為已解決衝突
$ git add
<
resolved
-file
>
撤銷$ git rm
<
resolved
-file
>
放棄工作目錄下的所有修改:
移除快取區的所有檔案(i.e. 撤銷上次$ git reset
--hard head
git add
):
$ git reset head
放棄某個檔案的所有本地修改:
重置乙個提交(通過建立乙個截然不同的新提交)$ git checkout head
將head重置到指定的版本,並拋棄該版本之後的所有修改:$ git revert
將head重置到上一次提交的版本,並將之後的修改標記為未新增到快取區的修改:$ git reset
--hard
將head重置到上一次提交的版本,並保留未提交的本地修改:$ git reset
$ git reset
--keep
Git 命令速查表
複製乙個已建立的倉庫 git clone ssh 建立乙個新的本地倉庫 git init顯示工作路徑下已修改的檔案 git status git diff把當前所有修改新增到下次提交中 git add把對某個檔案的修改新增到下次提交中 git add p提交本地的所有修改 git commit a提...
簡明 Git 命令速查表
複製乙個已建立的倉庫 git clone ssh 建立乙個新的本地倉庫 git init顯示工作路徑下已修改的檔案 git status git diff把當前所有修改新增到下次提交中 git add把對某個檔案的修改新增到下次提交中 git add p提交本地的所有修改 git commit a提...
Docker 命令速查表
1 容器生命週期管理 docker run 建立乙個新的容器並執行乙個命令 docker run options image command arg.options引數說明 引數說明 a stdin 指定標準輸入輸出內容型別 d後台執行容器,並返回容器的id i以互動式模式執行容器,通常與 t同時使...