git 常用命令

2021-09-25 13:35:24 字數 1202 閱讀 6642

初始化乙個git倉庫 git init

檢視分支:git branch

建立分支:git branch

切換分支:git checkout

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

合併某分支到當前分支(快速合併):git merge

普通合併(兩者的區別在於前者合併後看不出曾經做過合併,而後者合併

後的歷史會有分支記錄!):git merge --no-ff -m 「合併的資訊(tag)」develop

刪除分支:git branch -d

刪除遠端分支:git push origin --delete

新建乙個標籤 git tag

指定標籤資訊 git tag -a-m 「blablabla…」

用pgp簽名標籤 git tag -s-m 「blablabla…」

檢視所有標籤 git tag

推送乙個本地標籤 git push origin

推送全部未推送過的本地標籤 git push origin --tags

刪除乙個本地標籤 git tag -d

刪除乙個遠端標籤 git push origin :refs/tags/

檢視遠端庫資訊 git remote -v;

從本地推送分支 git push origin branch-name,如果推送失敗,先用git pull抓取遠端的新提交;

在本地建立和遠端分支對應的分支 git checkout -b branch-name origin/branch-name,本地和遠端分支的名稱最好一致;

建立本地分支和遠端分支的關聯 git branch --set-upstream branch-name origin/branch-name;

從遠端抓取分支 git pull,如果有衝突,要先處理衝突。

工作區的狀態 git status命

檢視修改內容 git diff

版本回滾 git reset --hard commit_id

檢視提交歷史 git log 檢視命令歷史 git reflog

常用命令 Git 常用命令大全

安裝教程可參照 廖雪峰老師的安裝教程。git config 在git中,使用git config 命令來配置 git 的配置檔案,git配置級別主要有3類 1 倉庫級別 local 本地 git 倉庫級別配置檔案,作用於當前倉庫。優先順序最高 2 使用者級別 global,全域性配置檔案,作用於所有...

git 常用命令

檢視是否存在檔案需要上傳 git status git add git commit m 建立遠端倉庫 git remote add origin 116.255.146.153 ruby cd work daily project.git 更新git fetch 116.255.146.153 r...

git常用命令

詳細 1,git log p 命令來顯示每一次提交與其父節點提交內容之間快照的差異。2,為了檢視載入 staged 而並未提交 not committed 的內容差異,可以使用 git diff stage 命令 在git 1.6之前的版本中,使用 cached 適應情形 在執行git commit...