常用的Git指令

2021-10-05 04:39:39 字數 1482 閱讀 4596

指令操作

git clone

轉殖遠端版本庫

git init

初始化本地版本庫

指令操作

git status

檢視狀態

git diff

檢視變更內容

git add .

跟蹤所有改動過的檔案

git add 檔名

跟蹤指定的檔案

git mv 舊名字 新名字

檔案改名

git rm 檔名

刪除檔案

git rm --cached 檔名

停止跟蹤檔案但不刪除

git commit -m 「commit message」

提交所有更新過的檔案

git commit --amend

修改最後一次提交

指令操作

git log

檢視提交歷史

git log -p 檔名

檢視指定檔案的提交歷史

git blame 檔名

以列表方式檢視指定檔案的提交歷史

指令操作

git reset --hard head

撤銷工作目錄中所有未提交檔案的修改內容

git checkout head 檔名

撤銷指定的未提交檔案的修改內容

git revert commit

撤銷指定的提交

指令操作

git branch

顯示所有本地分支

git checkout branch/tag

切換到指定分支或標籤

git branch new-branch

建立新分支

git branch -d branch

刪除本地分支

git tag

列出本地所有的標籤

git tag tagname

基於最新提交建立標籤

git tag -d tagname

刪除標籤

指令操作

git merge branch

合併指定分支到當前分支

git rebase branch

衍合指定分支到當前分支

指令操作

git remote -v

檢視遠端版本庫資訊

git remote show remote

檢視指定遠端版本庫資訊

git remote add remote url

新增遠端版本庫

git fetch remote

從遠端庫獲取**

git pull remote brach

git push remote :branch/tag-name

刪除遠端分支或標籤

git push --tags

上傳所有標籤

git的常用指令

git安裝 1,初始化 git倉儲 倉庫 這個倉庫會存放,git對我們專案 進行備份的檔案 在專案目錄右鍵開啟 git bash 命令 git init 2,自報家門 就是在 git中設定當前使用的使用者是誰 每一次備份都會把當前備份者的資訊儲存起來 命令 配置使用者名稱 git config gl...

git常用的指令

最近專案從svn遷入到git,常用的git指令需要用到 git config global user.name user name git config global user.email email email.com 初始化 git init 加倉庫 git remote add origin ...

Git的常用指令

建立版本庫 mkdir learngit cd learngit pwd users michael learngit pwd命令用於顯示當前目錄。在我的mac上,這個倉庫位於 users michael learngit 初始化乙個git倉庫 git init initialized empty ...