Git Bash

Git for Windows 提供源自Linux/Unix 指令操作Window 檔案系統,更可以將靜態網頁 Push 上傳到 GitHub

安裝

建立D:\App資料夾(選擇性)

前往 Git - Downloading Packag ,按 64-bit Git for Windows Portable

開啟 PortableGit-2.42.0.2-64-bit.7z.exe (我下載時的版本,這是以7-Zip打包的可執行檔),安裝的資料夾改為 D:\App\PortableGit ➜ 按 [OK] 複製D:\App\PortableGit\內的git-bash.exe,至上一層D:\App,貼上捷徑

開啟 git-bash 作底下設置
按滑鼠右鍵 按 [Window] ➜ UI language 選取 [zh_TW] ➜ 按 [Apply] ➜ 按 [Save]
輸入 echo $PATH ( 可複製再貼至git-bash),git-bash的 複製、貼上 快速鍵分別為 Ctrl+Ins、Shift+Ins 安裝wget 與測試
前往GNU Wget下載 x64 EXE
由 echo $PATH 得知將 wget.exe 移至 D:\App\PortableGit\usr\bin\ 內,
於 git-bash 貼上 wget https://diii.neocities.org/img/git02.webp下載上一張圖片做測試。

git-bash 的 Bash 就是能從檔案中讀取命令並執行,而這檔案稱為shell script。將底下 shell script 以原始碼編輯器(如Notepad++)存至 D:\App\PortableGit\hello.sh,於git-bash 貼上 sh hello.sh 執行(註: Windows 不需 chmod +x hello.sh)

#!/bin/bash
Reset=$(tput sgr0)
Blue=$(tput setaf 4)

echo -e "Hello ${Blue}World${Reset}!"

如同cmd快速進入中文資料夾,於 git-bash 貼上 cd "D:\相簿\登山"

GitHub SSH 連線

如果檔案不上傳至 GitHub,以下操作可不作😁。

前往 GitHub 註冊,連線有 SSH 與 HTTPS 兩種,底下只說明 SSH 方法,更多資訊可參閱使用 SSH 连接到 GitHub

設置使用者的 Email 及使用者名稱,可再參閱使用者設定
於 git-bash 貼上git config --global user.email "you@example.com" ,you@example.com 改為你的。
於 git-bash 貼上git config --global user.name "Your Name" ,Your Name 改為你的。

生成 SSH 公鑰匙和私鑰匙
於 git-bash 貼上 ssh-keygen,會在 C:\Users\your_name\.ssh 資料夾裡生成 id_rsa, id_rsa.pub 兩個檔案。id_rsa.pub是公開金鑰,id_rsa是私密金鑰。
於 git-bash 貼上 cat ~/.ssh/id_rsa.pub 顯示剛剛建立的公鑰,並且複製
PS: id_rsa.pub 也可以使用Notepad++開啟。 將 公鑰 貼到 GitHub SSH keys
New SSH key ➜ 於 Key 欄位 貼上 ➜ 按 Add SSH key

測試 GitHub SSH 連線
於 git-bash 貼上 ssh -T git@github.com,過程如下:

Are you sure you want to continue connecting (yes/no/[fingerprint])?
輸入 yes
Warning: Permanently added 'github.com' (ED25519) to the list of known hosts. Hi diy99! You've successfully authenticated, but GitHub does not provide shell access.