← 從零開始學 Git
第 2 課,共 17 課 · 10 XP
git init——建立儲存庫
理論與題目說明
機器翻譯,尚未經母語人士審閱。
git init 把一般的資料夾變成儲存庫:在裡面建立隱藏資料夾 .git。
git init
# Initialized empty Git repository in /repo/.git/
git 對專案知道的一切都在 .git 裡:歷史、分支、設定。刪掉 .git,資料夾就變回一般的資料夾,整段歷史都會消失。工作檔案則會留著。
新儲存庫預設的分支名稱是 main。在舊版的 git 或舊專案裡,你會看到 master 這個名字。
git init 每個專案只執行一次。專案已經在 GitHub 上的話,就用 git clone <url> 取代 init——在遠端儲存庫那一課會詳細介紹。
題目。 用 git init 建立儲存庫,再用 ls -a 看隱藏檔案。應該會看到 .git。