# GitHub 基礎教學:拉取與上傳 Repositories

ChatGPT 教學系列 2 min read
Table of Contents

GitHub 基礎教學:拉取與上傳 Repositories

適用對象:Git 初學者、希望學會從 GitHub 拉下專案與上傳檔案的開發者。


📥 1. 從 GitHub 拉取(Clone)專案

步驟一:取得 Repository 的網址

  1. 前往 GitHub 上的專案頁面。
  2. 點選綠色的 <> Code 按鈕。
  3. 複製 HTTPS 連結(例如:https://github.com/username/repo.git)。

步驟二:在本機拉取專案

Terminal window
git clone https://github.com/username/repo.git

執行後會在目前資料夾下建立一個同名的資料夾。


✏️ 2. 修改並上傳(Push)檔案

步驟一:進入專案資料夾

Terminal window
cd repo

步驟二:修改或新增檔案

例如新增一個 hello.md

Terminal window
echo "# Hello GitHub" > hello.md

步驟三:提交(commit)變更

Terminal window
git add . # 將所有變更加入追蹤
git commit -m "新增 hello.md"

步驟四:推送(push)到 GitHub

Terminal window
git push origin main

🔐 若遇到權限問題,請確認你已設定 SSH 金鑰或使用 HTTPS 與 Token 驗證。


🔁 3. 常見補充指令

指令功能
git status查看當前狀態
git pull從 GitHub 拉取最新更新
git log查看提交歷史
git remote -v顯示遠端 GitHub 的網址

🎉 恭喜!

你已完成 GitHub 上的 clone / commit / push 基礎流程!

如果有多個分支、合併請求等進階需求,也可以再深入學習。


My avatar

Thanks for reading my blog post! Feel free to check out my other posts or contact me via the social links in the footer.


More Posts

Comments