Git

Git – Reference

個人資料登記

  • git config --global user.name "<name>"
  • git config --global user.email "<email_address>"

Basic Snapshotting

初始化 Repository:git init

新增文件至下次變更:git add

新增所有檔案:git add .

新增特定檔案:git add <filename>

新增特定資料夾:git add <dirpath>/

查看尚未登記的所有變更:git status

查看 未 add / 已 add 的變更:git diff [--staged]

登記所有變更為新 commit:git commit -m <message>

git reset

git reset --soft <commit_id>

git reset --hard <commit_id>

檢查與比較 Inspection and Comparison

git log

Branch 相關操作

git branch [<branch_name>]

[建立並]切換分支:git switch [-c] [<branch_name>]

git merge <another_branch_name>

Sharing and Updating Projects

推送至 Remote Repository:git push

啦取至 Remote Repository:git pull

排除追蹤特定檔案:.gitignore

  • <filename>
  • 排除資料夾及其內所有內容:<dirpath>/
    只排除資料夾中的檔案 (不包含該資料夾及其子資料夾):<dirpath>/*
  • *.<extension>
  • 確保某個檔案絕對不會被排除
    <dirpath>/*
    !<dirpath>/<filename>

Last Updated on 2026/01/26 by A1go

目錄
Bitnami