git的常用操作指令

2021-09-24 04:22:46 字數 2691 閱讀 9332

命令

實現操作

備註git init

在現有目錄中初始化倉庫

git add

對指定檔案的跟蹤

後面接你想跟蹤的檔案

git commit

提交更新

git clone

轉殖現有的倉庫

後面接你的git庫位址

git status

檢查當前檔案狀態

git diff

檢查具體修改了什麼地方

git diff --cached

把已暫存的新增到下次提交裡的內容

與git diff --staged類似

git rm

移除檔案

git log

檢視提交歷史

git commit --amend

撤消操作

git reset head

取消暫存的檔案

git checkout – [file]

撤消對檔案的修改

這是乙個危險的命令,你對那個檔案做的任何修改都會消失

git remote

檢視遠端倉庫

git remote -v會顯示需要讀寫遠端倉庫使用的 git 儲存的簡寫與其對應的 url。

git remote add

新增遠端倉庫

git remote add pb

git fetch pb

拉取pb 的倉庫中有但你沒有的資訊

git fetch [remote-name]

git push origin master

推送到遠端倉庫

git push [remote-name] [branch-name]

git remote show origin

檢視遠端倉庫

git remote show [remote-name]

git remote rename

遠端倉庫的重新命名

git remote rename pb paul(pb 重新命名為 paul)

git remote rm

遠端倉庫的重新命名移除

git remote rm paul(移除paul)

git tag

列出標籤

git branch testing

建立分支

git checkout testing

分支切換

git checkout -b iss53

新建分支iss53

git branch -d hotfix

刪除分支hotfix

git checkout master / git merge iss53

合併分支

把分支iss53 合併到分支master 上

git mergetool

遇到衝突時的分支合併

會啟動乙個合適的視覺化合併工具,並帶領你一步一步解決這些衝突

git branch -v

檢視每乙個分支的最後一次提交

git branch --merged

檢視哪些分支已經合併到當前分支

git branch --no-merged

檢視所有包含未合併工作的分支

git fetch

更新你的遠端倉庫引用 (拉取)

git fetch teamone

來抓取遠端倉庫 teamone 有而本地沒有的資料

git 並不會抓取資料而是會設定遠端跟蹤分支 teamone/master 指向 teamone 的 master 分支

git pull

跟蹤分支

git 能自動地識別去哪個伺服器上抓取、合併到哪個分支。

git push origin --delete serverfix

從伺服器上刪除 serverfix 分支

git add .

git commit -m "提交說明"

git push

git checkout dev

git pull

git checkout hardy

git merge dev

git push origin hardy:hardy

git push origin hardy:dev

1、git add .

加入快取

2、git commit -m "完成移動端資料填充"

提交到本地倉庫

3、git push

提交到遠端倉庫

4、git checkout dev

切換分支

5、git pull

拉去分支**(注意:如果出現衝突需要手動解決衝突並執行1,2,3步驟)

6、git checkout hardy

切換分支

7、git merge dev

合併**

8、git push origin hardy:hardy

提交到遠端庫hardy分支

9、git push origin hardy:dev

提交到遠端庫dev分支

git常用操作指令

改變git小黑窗主題 合併分支篇 git資料夾 分為 暫存區和分支區 git initgit add index.html git add 新增全部檔案 git commit m 你的描述 git log git log pretey oneline 檢視所有的日誌檔案 包括版本回退過的和版本刪除過...

git常用操作指令

檢視本地和遠端所有分支 git branch a 將本地分支與遠端保持同步 git fetch 切換到主分支 git checkout master 合併遠端分支 git merge 遠端分支名 fatal remote origin already exists.遠端 已經存在 解決辦法 git ...

常用git指令操作

雜碎的知識點要時常記錄。雖然已經有github桌面應用了,但是事實上用了幾次指令以後發現用指令方便很多,而且即使有錯誤也會報錯,報錯也是一種學習 git指令 git clone 將github上指令複製到本地 git init 初始化專案檔案目錄,會在專案目錄中增加乙個.git用於上傳你的專案 gi...