git命令學習總結

2021-08-25 17:32:21 字數 1259 閱讀 8215

git log 顯示所有提交過的版本資訊

git reflog 可以檢視所有分支的所有操作記錄(包括commit和reset的操作),包括已經被刪除的commit記錄,git log則不能檢視已經刪除了的commit記錄

git reset 回退乙個版本,預設為mixed

建立遠端分支:在本地已有分支的情況下,git push origin 分支名。然後刪除本地分支,再執行git checkout -b dev origin/dev命令,將本地分支與遠端分支關聯

場景1:當你改亂了工作區某個檔案的內容,想直接丟棄工作區的修改時,用命令git checkout – file。

場景2:當你不但改亂了工作區某個檔案的內容,還新增到了暫存區時,想丟棄修改,分兩步,第一步用命令git reset head file,就回到了場景1,第二步按場景1操作。

建立的.git資料夾中,有stage的暫存區,有master分支,有指向master分支的head指標

git add:把檔案新增到暫存區

git commit:把暫存區的內容新增到master分支

git branch: 檢視當前分支

檢視分支:git branch

建立分支:git branch name

切換分支:git checkout name

建立+切換分支:git checkout -b name

合併某分支到當前分支:git merge name

刪除分支:git branch -d name

git log –graph –pretty=oneline –abbrev-commit: 檢視分支合併情況

git stash:將當前工作區儲存起來

git stash pop:恢復工作現場。

git stash list:多次stash,恢復的時候,先用git stash list檢視,然後恢復指定的stash

git branch -d name:強行刪除乙個還沒有合併的分支

推送失敗,有衝突:1)git pull orign 遠端分支名:把最新的提交從遠端分支抓下來,在本地解決衝突後,再提交

git pull提示no tracking information,則說明本地分支和遠端分支的鏈結關係沒有建立,用命令git branch –set-upstream-to branch-name origin/ branch-name。

find / -name 「*mysql」 /代表從選擇要模糊查詢的目錄,mysql代表要模糊查詢的名字

git 學習命令總結

git config global user.name knight git config global user.email xiaoge777888 126.com git config list git init git add 檔名 git commit m 描述資訊 合併 git comm...

Git命令學習總結

1.修改版本庫並建立新的提交記錄git commit git commit 2.建立乙個新的分支git branch 分支名 git branch newimage3.切換分支命令git checkout 分支名 git checkout 分支名 4.建立新分支時切換到新分支git checkout...

git基礎命令學習總結

git版本公升級 git clone git 列出所有 git 當時能找到的配置 git config list git config 來檢查 git 的某一項配置 使用 git 來對現有的專案進行管理 git init 轉殖遠端倉庫 git clone url 檢視檔案狀態 git status ...