Git 常用命令

2021-10-08 15:30:10 字數 1553 閱讀 2500

git clone **位址       將**轉殖到本地

git log    檢視所有提交日誌

git log -5   檢視最近5個提交日誌

git log --grep=key 或 git log --grep key    按關鍵字key查詢日誌(區分大小寫)

git log --author=jh   顯示提交者「jh」的所有提交日誌

git log file    檢視檔案file所有修改歷史

git show commit         檢視commit的修改內容    

git show commit --stat    以列表顯示commit版本修改的檔案

git show commit file      檢視檔案file的修改

git diff commit1 commit2    檢視兩次提交的不同

git diff commit1 commit2 --stat    以列表顯示兩次提交的不同

git diff  顯示所有檔案的詳細修改

git diff  --stat  以列表顯示修改的檔案

git reset commit  回退版本到commit

git reset --hard 回退到最近的乙個版本

git reset file 撤銷提交檔案file

git clean -fd  刪除新增檔案, 配合git reset使用清理**

git pull 更新**到最新版本

git rm file 從版本庫中刪除檔案

git rm --cached file 從版本庫中刪除跟蹤,但不刪除檔案

git status    檢視當前本地**修改狀態,一般分為已修改(modified)、已暫存(staged)、已提交(committed)

git checkout -- file  修改的檔案file回到修改前的狀態,也可以是目錄,如是目錄,目錄下所有修改的檔案回到修改前狀態

git add.將當前目錄的所有檔案加入暫存區

git addfile  將檔案file加入暫存區

git commit -m " "  提交到暫存區,引號內為標題描述

git push 提交暫存區的修改到遠端伺服器

//提交本地**到遠端伺服器的步驟

// 1、git add.

//2、git commit -m " "

//3、git push orgin 分支名     //提交到指定分支

git branch  檢視分支

git branch -a  檢視所有分支

git branch -v 檢視各個分支最後乙個提交物件的資訊

git checkout 分支名    切換到對應分支

git brand  test   建立分支test

git brand –d test    刪除test分支

git checkout –b test   建立新分支test,並且切換到test分支

git merge 分支名    合併分支

常用命令 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...