Git 安裝過程跟很久以前有些微不同,紀錄一下安裝過程。
環境:
Windows 11、Git 2.53.0
安裝步驟:
- 到官網 http://git-scm.com 下載最新版 Git,我下載的是 Git-2.53.0-64-bit.exe
- 執行安裝檔,安裝畫面按「Next」到下一步驟
- 選擇安裝到那個資料夾,按「Next」。
- 早期安裝的時候沒有 Git LFS 和 Scalar,這兩個我都照預設勾選,進行下一步。
Git LFS:https://git-lfs.com/
Git Large File Storage,一個對大型檔案進行版本控制的開源 Git 擴展。將大檔案(圖片、影片...)上傳至大檔案儲存服務,而與大檔案對應的指標檔案與其他程式碼檔案推送到 Git 倉庫中,以讓 Git 倉庫空間佔用減小。
Scalar:https://git-scm.tw/docs/scalar
管理大型 Git 倉庫的工具。 - 是否在開始選單建立資料夾,按「Next」。
- 預設使用什麼文字編輯器,依自己喜好選擇,這邊我用預設的 Vim
- 設定執行 git init 時,建立的儲存庫分支名稱。早期安裝時沒這設定,名稱是 master,不解為什麼這要設定,查了一下,原來是跟種族歧視有關(master/slave),以前還真沒想到這些用語背後隱含的文化意義。。
避免無心造成的紛爭,建議設定個中性的名稱。
目前 GitHub 是使用 main,所以我也設定為 main。 - 設定執行 Git 指令的方式,以前我習慣不動到原本系統環境變數 PATH 的設定(Git Bash only)。
但這次看到安裝畫面建議選第二項,優點是可讓其他要使用 Git 的軟體,在環境變數 PATH 裡找到 Git 使用。所以我選預設的第二項。 - 使用 SSH 時,ssh.exe 指令使用 Git 自帶捆綁的 OpenSSH ,還是外部的 OpenSSH。
我安裝過 Windows 選用功能裡的 OpenSSH (設定 --> 系統 --> 選用功能),路徑 C:\Windows\System32\OpenSSH,所以我選擇使用外部的 OpenSSH。
相關:開始使用 Windows 版 OpenSSH 伺服器 | Microsoft Learn - 使用 HTTPS 時,使用 OpenSSL library 還是 Windows 原生的安全通道 library。
Windows 原生的安全通道 library,優點是可使用公司內部發的 CA 證書。
我選擇 Windows 原生的安全通道 library。
相關:在高度網路管制的企業內部如何設定 Git 連接 Azure Repos 上的儲存庫 | The Will Will Web - 換行轉換處理,在 Windows 安裝選第一項,checkout LF 轉成 CRLF,commit CRLF 轉成 LF。
這務必大家處理原則都一致,避免發生因換行轉換原則不同,誤判每行都有修改。 - Git Bash 使用哪種終端機操作,MinTTY 或 Windows內建終端機。
這裡選 MinTTY,比Windows內建終端機好用。 - 選擇 git pull 指令的行為,早期的安裝過程也無此選項。
我通常都是先 git fetch,再看怎麼做,所以直接保留安裝程式預設的第一項。
第一種:git pull = git pull --no-rebase = git fetch + git merge
第二種:git pull = git pull --rebase = git fetch + git rebase
第三種:git pull = git pull --ff-only ,如果本機分支與遠端分支出現分歧,則會失敗。 - 選擇是否使用 Git Credential Manager(GCM、Git 認證管理員) 。
一個為 Git 提供無縫的多因素 HTTP(S) 身份驗證工具,優點不用每次連到 HTTP(S) 遠端儲存庫都要輸入密碼。
當 git push 到遠端儲存庫時,系統會自動開啟一個 GCM 窗口,引導完成登入。然後 GCM 儲存認證(儲存在 Windows 認證管理員),之後在同一儲存庫中的後續 Git 命令將重複使用 現有的認證(credentials or tokens、憑證或令牌),直到這些認證失效。
安裝畫面上的兩個連結:Cross-platform Git Credential Manager、here - 勾選 Enable file system caching:將資料快取到記憶體,供特定操作使用,此設定可顯著改善效能。
- 安裝完成
- 以上選擇安裝完後,Git 系統的設定值如下
$ git config --list --system diff.astextplain.textconv=astextplain filter.lfs.clean=git-lfs clean -- %f filter.lfs.smudge=git-lfs smudge -- %f filter.lfs.process=git-lfs filter-process filter.lfs.required=true http.sslbackend=schannel core.autocrlf=true core.fscache=true core.symlinks=false pull.rebase=false credential.helper=manager credential.https://dev.azure.com.usehttppath=true init.defaultbranch=main
參考:
- https://git-lfs.com/
Git Large File Storage | Git Large File Storage (LFS) replaces large files such as audio samples, videos, datasets, and graphics with text pointers inside Git, while storing the file contents on a remote server like GitHub.com or GitHub Enterprise. - https://www.alibabacloud.com/help/tc/yunxiao/user-guide/how-to-use-git-lfs
如何使用Git LFS? - Alibaba Cloud DevOps - 阿里雲 - https://www.webdong.dev/zh-tw/post/how-i-use-git-lfs-to-manage-large-git-files/
我如何使用 Git LFS 來託付大型 Git 檔案? - 網頁東東 - https://www.ithome.com.tw/news/140094
GitHub 10月起將以Main取代Master作為新Git儲存庫預設名稱 | iThome - https://pages.carm.cc/doc/branch-main.html
为什么Git分支开始从“master”变为“main”了? - https://git-scm.com/docs/git-pull
Git - git-pull Documentation - https://blog.miniasp.com/post/2022/05/18/Clear-Azure-Repos-Authority-Cache-using-Git-Credential-Manager
如何使用 Git Credential Manager 快速清除 Azure Repos 使用者認證快取 | The Will Will Web - https://github.com/git-ecosystem/git-credential-manager
GitHub - git-ecosystem/git-credential-manager: Secure, cross-platform Git credential storage with authentication to GitHub, Azure Repos, and other popular Git hosting services. - https://git-scm.com/docs/git-credential
Git - git-credential Documentation - https://learn.microsoft.com/zh-tw/azure/devops/repos/git/set-up-credential-managers?view=azure-devops
使用認證管理員連線到您的 Git 存放庫 - Azure Repos | Microsoft Learn - https://learn.microsoft.com/en-us/windows-hardware/drivers/install/certificate-stores
Certificate Stores - Windows drivers | Microsoft Learn
















沒有留言:
張貼留言