GitLab上git日常指令操作

 
由於時常忘記所以還是做一下這塊的筆記

之前的筆記文章是從自己建立repository切入
淺談版本控制示意圖原理_作法_悲觀鎖定VS樂觀鎖定VS分散式版本_傳統Delta儲存.vs.DAG儲存


電腦環境上配置
git  config   --global   user.name  "你的名字"
git  config  --global  user.email  "你的電子郵件"

列出目前電腦上git配置設定參數
git config --list 

針對user name印出
git config user.name

針對email印出
git config user.email



通常起手式
要馬自己建立repository

要馬Clone(複製)別人的 Repository


這次先以比較常會碰到的
clone他人repository的情境來看

GitLab上分支




首先要針對自己的branch clone下來的操作
git clone --branch <branchname> <remote-repo-url>
git clone -b <branchname> <remote-repo-url>
假如有四個分支
git clone --branch {分支名稱1} https://XXXXXXXX.git
git clone --branch {分支名稱2} https://XXXXXXXX.git
git clone --branch {分支名稱3} https://XXXXXXXX.git
git clone --branch {分支名稱4} https://XXXXXXXX.git

比方我要取我的分支下來做後續程式開發
git clone --branch KuanYu https://XXXXXXXX.git

接下來的操作都是當前已經切換到在含有.git目錄下的cmd或者linux環境目錄下的操作


status 指令
查看(初始確認)
通常都會確認目前checkout或者clone下來的git版控狀態一些概要資訊
比方所處的分支(確認有沒有抓錯)

這裡我拿一個是clone我的
一個是clone另一個人的

git status




log指令 :查看過去commit紀錄(記得若要跳出來原本的指令cmd狀態可按q)
git log



git log --stat
則可更詳細看到變更的詳細內容(細到異動的檔案)




branch指令



若要顯示當前的local端分支
git branch

若要顯示remote端分支
git branch -r

若要把所有分支(包含remote跟local)顯示出來則可下
git branch -a




show-branch指令



若要查看分支下版控的歷史提交紀錄(commit紀錄)可使用show-branch指令

顯示當前的local端分支含commit紀錄
git show-branch


顯示remote端分支含commit紀錄
git show-branch -r


顯示所有(local+remote端)分支含commit紀錄
git show-branch -a




diff指令
最常用的莫過於比較最新版跟上一版差異
git diff HEAD^ HEAD








Ref:
https://www.jquery-az.com/list-branches-git/
https://www.freecodecamp.org/news/git-clone-branch-how-to-clone-a-specific-branch/
https://stackoverflow.com/questions/9483757/how-to-exit-git-log-or-git-diff
What is the difference between git clone and checkout?
https://stackoverflow.com/questions/7298598/what-is-the-difference-between-git-clone-and-checkout








留言

這個網誌中的熱門文章

經得起原始碼資安弱點掃描的程式設計習慣培養(五)_Missing HSTS Header

經得起原始碼資安弱點掃描的程式設計習慣培養(三)_7.Cross Site Scripting(XSS)_Stored XSS_Reflected XSS All Clients

(2021年度)駕訓學科筆試準備題庫歸納分析_法規是非題