🐙 Git และ GitHub CLI
คำสั่ง Git ขั้นพื้นฐานและขั้นสูงสำหรับการควบคุมเวอร์ชัน การสร้าง branch การจัดการ repo ระยะไกล stash tags และ GitHub CLI
🔹 คำสั่งพื้นฐาน
คำสั่ง |
ตัวอย่าง |
คำอธิบาย |
|---|---|---|
git add |
เพิ่มไฟล์ไปยัง staging area | |
git add file.txt |
เพิ่มไฟล์เฉพาะสำหรับ commit ถัดไป |
|
git add . |
เพิ่มการเปลี่ยนแปลงทั้งหมดในไดเรกทอรีปัจจุบันและด้านล่าง |
|
git add -p |
เลือกส่วนของไฟล์ที่จะ stage แบบโต้ตอบ (เหมาะสำหรับ partial commit) |
|
git clone |
โคลน repository ลงในไดเรกทอรีใหม่ | |
git clone -b branch_name URL |
โคลนเฉพาะ branch ที่ระบุ (แทนค่าเริ่มต้น) |
|
git clone --depth 1 URL |
โคลนเฉพาะ commit ล่าสุด (shallow copy) เพื่อลดเวลาและพื้นที่ |
|
git commit |
บันทึกการเปลี่ยนแปลงลง repository | |
git commit -m "Initial commit" |
commit พร้อมข้อความโดยไม่เปิด editor |
|
git commit -a -m "Fix bugs" |
stage และ commit ไฟล์ที่แก้ไขทั้งหมดพร้อมข้อความ |
|
git commit --amend |
อัปเดต commit ล่าสุด (เปลี่ยนข้อความหรือเพิ่มการเปลี่ยนแปลง) |
|
git commit --fixup abc1234 |
สร้าง fixup commit เพื่อ squash อัตโนมัติใน interactive rebase |
|
git config |
ตั้งค่าและเรียกดู options ของ repo หรือ global | |
git config --global user.name "Name" |
ตั้งค่า Git username ระดับ global |
|
git config --global user.email "email@example.com" |
ตั้งค่า Git email ระดับ global |
|
git config --list |
แสดงการตั้งค่า Git ทั้งหมด (name, email, editor ฯลฯ) |
|
git diff |
แสดงการเปลี่ยนแปลงระหว่าง commits, commit กับ working tree ฯลฯ | |
git diff HEAD |
แสดงสิ่งที่คุณเปลี่ยนแปลงตั้งแต่ commit ล่าสุด (unstaged) |
|
git diff --staged |
แสดงสิ่งที่จะรวมในการ commit ถัดไป |
|
git diff --word-diff HEAD~1 |
แสดงความแตกต่างในระดับคำ (word-level) |
|
git grep |
ค้นหาภายในไฟล์ของ repository | |
git grep "functionName" |
ค้นหาทุกการอ้างอิง |
|
git grep -n "TODO" |
ค้นหา |
|
git grep -i "login" |
ค้นหาคำว่า |
|
git init |
สร้าง repo Git ว่างใหม่ หรือรีอินิท repo ที่มีอยู่ | |
git init my-project |
อินิท repo ใหม่ในไดเรกทอรี my-project |
|
git init --bare |
อินิทเป็น bare repository |
|
git log |
แสดง log ของ commit | |
git log --oneline |
แสดงประวัติ commit แบบบรรทัดเดียวกะทัดรัด |
|
git log --graph --all |
แสดงทุก branch ในรูปแบบกราฟ |
|
git log -p --stat |
แสดง patch และสถิติการเปลี่ยนไฟล์ของ commits |
|
git reset |
ยกเลิกการ stage ไฟล์ โดยยังคงการเปลี่ยนแปลงใน working directory | |
git reset HEAD file.txt |
นำไฟล์ออกจาก staging (การแก้ไขยังคงอยู่) |
|
git reset --hard HEAD~1 |
ย้อนกลับหนึ่ง commit และลบการเปลี่ยนแปลงทั้งหมด (ย้อนกลับไม่ได้!) |
|
git reset --soft HEAD~1 |
ยกเลิก commit ล่าสุด แต่เก็บการเปลี่ยนแปลงไว้เพื่อ commit ใหม่ |
|
git reset --mixed HEAD~1 |
ยกเลิก commit แต่เก็บการเปลี่ยนแปลงแบบ unstaged |
|
git show |
แสดง objects หลากหลายชนิด | |
git show <commit_hash> |
แสดงการเปลี่ยนแปลงและข้อความของ commit เฉพาะ |
|
git show HEAD~1 |
แสดง commit ก่อน commit ปัจจุบัน |
|
git show --stat |
แสดงสรุปการเปลี่ยนไฟล์สำหรับ commit ล่าสุด |
|
git status |
แสดงสถานะ working tree | |
git status -s |
แสดงสถานะแบบย่อ |
|
git status -b |
แสดง branch ปัจจุบันและสถานะไฟล์ |
🌿 Branching และ Merging
คำสั่ง |
ตัวอย่าง |
คำอธิบาย |
|---|---|---|
git branch |
สร้าง แสดงรายการ หรือลบ branches | |
git branch new-feature |
สร้าง branch ใหม่ชื่อ |
|
git branch -d old-feature |
ลบ branch ท้องถิ่นชื่อ |
|
git checkout |
สลับ branch หรือกู้คืนไฟล์จาก commit อื่น | |
git checkout main |
สลับไปยัง branch |
|
git checkout -b new-branch |
สร้างและสลับไปยัง branch ใหม่ชื่อ |
|
git switch |
สลับ branch (เป็นทางเลือกที่ง่ายกว่า checkout) |
|
git switch main |
สลับไปยัง branch |
|
git switch -c feature-x |
สร้างและสลับไปยัง branch ใหม่ชื่อ |
|
git switch new-feature |
สลับไปยัง branch ที่มีอยู่ชื่อ |
|
git merge |
รวมการเปลี่ยนแปลงจาก branch อื่นเข้ามาใน branch ปัจจุบัน | |
git merge new-feature |
merge branch |
|
git merge --no-ff new-feature |
สร้าง merge commit เสมอ (แม้ fast-forward จะเป็นไปได้) |
|
git merge --abort |
ยกเลิก merge และย้อนการเปลี่ยนแปลงหากเกิด conflict |
|
git rebase |
ย้ายหรือ reapply commits ไปยัง commit ฐานใหม่ | |
git rebase main |
reapply commits ของ branch บน branch |
|
git rebase -i HEAD~3 |
แก้ไข commits 3 อันล่าสุดแบบ interactive |
|
git rebase --abort |
หยุดและยกเลิก rebase ที่กำลังทำอยู่ |
|
git rebase -i --autosquash HEAD~5 |
squash commits ที่ทำเครื่องหมายเป็น fixup/squash ระหว่าง interactive rebase |
|
git cherry-pick |
นำ commit เฉพาะจาก branch อื่นมาใช้ | |
git cherry-pick <hash> |
ใช้ commit (ตาม hash) เฉพาะกับ branch ปัจจุบัน |
|
git cherry-pick --continue |
ดำเนินการต่อหลัง conflict ของ cherry-pick |
|
git cherry-pick A^..B |
นำ commit ช่วง |
📡 Repository ระยะไกล
คำสั่ง |
ตัวอย่าง |
คำอธิบาย |
|---|---|---|
git remote |
จัดการลิงก์ไปยัง remote repositories (เช่น GitHub) | |
git remote -v |
แสดงชื่อ remote และ URL |
|
git remote add origin URL |
เพิ่ม remote repository ชื่อ |
|
git pull |
ดาวน์โหลดและ merge การเปลี่ยนแปลงจาก remote branch | |
git pull origin main |
fetch และ merge การเปลี่ยนแปลงจาก remote |
|
git pull --rebase origin main |
fetch และ rebase branch ปัจจุบันกับ remote branch |
|
git push |
อัปโหลดการเปลี่ยนแปลงจาก local ไปยัง remote | |
git push origin main |
push branch |
|
git fetch |
ดาวน์โหลดการเปลี่ยนแปลงจาก remote โดยไม่ merge | |
git fetch origin |
fetch การอัปเดตทั้งหมดจาก |
|
git fetch origin main |
fetch เฉพาะ branch |
|
git fetch --all |
fetch การอัปเดตจาก remote ทั้งหมด |
|
git fetch --prune |
ล้าง branch ที่ถูกลบออกจาก remote |
|
git fetch --dry-run |
แสดงสิ่งที่จะ fetch โดยไม่ดาวน์โหลดจริง |
|
git fetch origin +main |
บังคับอัปเดต tracking branch ( |
📦 Stash และ Cleanup
คำสั่ง |
ตัวอย่าง |
คำอธิบาย |
|---|---|---|
git stash |
บันทึกการเปลี่ยนแปลงที่ยังไม่ commit ชั่วคราว | |
git stash |
บันทึกไฟล์ที่แก้ไขและ staged แล้วรีเวิร์กไปยัง commit ล่าสุด |
|
git stash apply |
นำการเปลี่ยนแปลง stash ล่าสุดมาใช้ (stash ยังอยู่) |
|
git stash pop |
นำ stash ล่าสุดมาใช้และลบออก |
|
git stash list |
แสดงรายการ stash ทั้งหมด |
|
git stash branch feature-fix |
สร้าง branch ใหม่แล้ว apply stash ล่าสุด |
|
git clean |
ลบไฟล์ที่ไม่ถูก track อย่างถาวร (ไม่อยู่ใน Git) | |
git clean -f |
ลบไฟล์ untracked ในไดเรกทอรีปัจจุบัน |
|
git clean -fd |
ลบไฟล์และโฟลเดอร์ untracked |
|
git clean -n |
แสดงตัวอย่างสิ่งที่จะถูกลบ (dry run) |
🏷️ Tags
คำสั่ง |
ตัวอย่าง |
คำอธิบาย |
|---|---|---|
git tag |
สร้าง แสดงรายการ หรือลบ tags เพื่อระบุจุดในประวัติ (เช่น releases) | |
git tag -a v1.0 -m "Version 1.0" |
สร้าง annotated tag |
|
git tag -d v1.0 |
ลบ tag ท้องถิ่น |
|
git push |
อัปโหลด commits, branches และ tags จาก local ไปยัง remote | |
git push origin --tags |
push tags ทั้งหมดไปยัง remote (มีประโยชน์หลัง tagging หลายเวอร์ชัน) |
|
git push origin v1.0 |
push tag เฉพาะ (เช่น |
|
git push origin :refs/tags/v1.0 |
ลบ tag |
🛠️ การแก้ไข Conflict
คำสั่ง |
ตัวอย่าง |
คำอธิบาย |
|---|---|---|
git mergetool |
เปิดเครื่องมือแบบ visual เพื่อช่วยแก้ merge conflict | |
git mergetool --tool=meld |
ใช้ merge tool เฉพาะ (เช่น Meld) เพื่อแก้ conflict |
|
git rerere |
ให้ Git จดจำวิธีแก้ merge conflict ที่เคยทำ | |
git config --global rerere.enabled true |
เปิดใช้งานการ reuse การแก้ conflict ที่ผ่านมาโดยอัตโนมัติ |
|
git rerere status |
แสดงไฟล์ที่มีการบันทึกวิธีแก้ conflict |
|
git rerere diff |
แสดงสิ่งที่ Git บันทึกไว้เพื่อใช้ในอนาคต |
⚙️ คำสั่งขั้นสูง
คำสั่ง |
ตัวอย่าง |
คำอธิบาย |
|---|---|---|
git bisect |
ใช้ binary search เพื่อหาว่า commit ไหนนำ bug เข้ามา | |
git bisect start |
เริ่ม binary search ระหว่าง commit ดีและ commit แย่ |
|
git bisect bad |
ทำเครื่องหมาย commit ปัจจุบันว่า “bad” |
|
git bisect good <commit> |
ทำเครื่องหมาย commit ที่ “good” |
|
git blame |
แสดงว่าใครแก้ไขแต่ละบรรทัดของไฟล์ครั้งล่าสุด พร้อม revision และ author | |
git blame file.txt |
แสดงผู้แก้ไขและ commit ของทุกบรรทัด |
|
git blame -L 10,20 file.txt |
แสดง blame เฉพาะบรรทัด 10 ถึง 20 |
|
git blame --show-email file.txt |
แสดงอีเมลของผู้แก้ไขพร้อมการเปลี่ยนบรรทัด |
|
git reflog |
ดูและจัดการ reference log (reflog) ของ branch movements และ HEAD | |
git reflog show main@{1.week.ago} |
ดูว่า branch |
|
git reflog expire --expire=30.days --dry-run |
ดู entries ใน reflog ที่เกิน 30 วันและสามารถลบได้ |
|
git reflog delete HEAD@{2} |
ลบ reflog entry เฉพาะ (ใช้ด้วยความระวัง) |
|
git submodule |
เพิ่ม อินิท อัปเดต หรือตรวจสอบ submodules (repo ซ้อน) | |
git submodule add URL path |
เพิ่ม repo ภายนอกเป็น submodule |
|
git submodule update --init |
อินิทและดาวน์โหลด submodules ทั้งหมดที่ระบุ |
|
git submodule foreach git pull |
รัน |
|
git submodule sync --recursive |
ซิงค์ submodule URLs หลังจากเปลี่ยน |
|
git submodule update --remote --merge |
อัปเดต submodules ไปยัง commit ล่าสุดของ remote |
|
git archive |
สร้าง archive (zip, tar ฯลฯ) ของไฟล์จาก commit หรือ branch | |
git archive --format=zip HEAD > archive.zip |
สร้าง ZIP archive ของโปรเจกต์ที่ HEAD |
|
git archive -o release.tar.gz HEAD |
สร้าง |
|
git archive --format=tar --prefix=project/ HEAD \| gzip > project.tar.gz |
สร้าง |
|
git gc |
ลบไฟล์ที่ไม่จำเป็นและเพิ่มประสิทธิภาพ repo | |
git gc --aggressive |
ทำการ cleanup และ optimize อย่างเต็มรูปแบบ |
|
git gc --prune=now |
ลบ objects ที่ไม่สามารถเข้าถึงได้ทันที (อันตรายหากไม่แน่ใจ) |
|
git shortlog |
สรุปอย่างรวดเร็วของผู้เขียนและ commits | |
git shortlog -e |
แสดงรายชื่อผู้เขียนพร้อมอีเมล |
|
git shortlog -s -n |
แสดงจำนวน commits ต่อผู้เขียน จัดเรียงตามจำนวน |
|
git shortlog -sne |
เช่นเดียวกันแต่รวมชื่อและอีเมล — เหมาะสำหรับการติดตาม activity |
|
git revert |
สร้าง commit ใหม่ที่ย้อนการเปลี่ยนแปลงจาก commit ก่อนหน้า โดยไม่เขียนประวัติใหม่ | |
git revert HEAD |
ย้อน commit ล่าสุดด้วย commit ใหม่ |
|
git revert <commit_hash> |
ย้อน commit เฉพาะ (ตาม hash) อย่างปลอดภัยด้วย commit ใหม่ |
🐙 GitHub CLI
ghช่วยให้คุณจัดการ GitHub จาก terminal ได้
คำสั่ง |
ตัวอย่าง |
คำอธิบาย |
|---|---|---|
gh auth login |
ยืนยันตัวตนกับโฮสต์ GitHub เพื่อให้ CLI สามารถโต้ตอบกับบัญชีของคุณได้ | |
gh auth login --with-token < mytoken.txt |
ยืนยันตัวตนโดยใช้ personal access token ที่เก็บไว้ในไฟล์ ( |
|
gh auth login --hostname enterprise.internal |
ยืนยันตัวตนกับ GitHub Enterprise server (ไม่ใช่ github.com) |
|
gh repo clone |
โคลน GitHub repository มายังเครื่อง local | |
gh repo clone user/repo |
โคลน repo ที่เป็นของ |
|
gh repo clone cli/cli -- --depth=1 |
โคลน repository โดยดาวน์โหลดเฉพาะ commit ล่าสุด เพื่อความรวดเร็วและประหยัดพื้นที่ |
|
gh repo clone cli/cli workspace/cli |
โคลน repository ลงโฟลเดอร์กำหนดเอง |
|
gh issue list |
แสดง issues ใน GitHub repository โดยสามารถกรองด้วยเงื่อนไขต่าง ๆ | |
gh issue list --assignee "@me" |
แสดง issues ที่ assign ให้คุณ |
|
gh issue list --state all |
แสดง issues ทั้งหมด (open และ closed) |
|
gh issue list --search "error no:assignee sort:created-asc" |
แสดง issues ที่มีคำว่า “error” ไม่ได้ assign และเรียงตามวันที่สร้างแบบเก่าไปใหม่ |
|
gh pr create |
สร้าง pull request บน GitHub ผ่าน CLI | |
gh pr create --title "..." |
สร้าง pull request พร้อมชื่อเรื่องที่กำหนด |
|
gh pr create --project "Roadmap" |
ลิงก์ pull request เข้ากับ GitHub project ชื่อ “Roadmap” |
|
gh pr create --base develop --head monalisa:feature |
สร้าง PR จาก branch |
|
gh repo create |
สร้าง GitHub repository ใหม่ผ่าน CLI | |
gh repo create my-project |
สร้าง repository ชื่อ |
|
gh repo create my-project --public --clone |
สร้าง public repository และโคลนลงเครื่อง local |
|
gh repo create my-project --private --source=. --remote=upstream |
สร้าง private remote repo จากโฟลเดอร์ปัจจุบันและเพิ่ม remote ชื่อ |
💡 Git Aliases (ช็อตคัตที่มีประโยชน์)
ตั้งค่า alias เพื่อเร่งการทำงานกับคำสั่ง Git ที่ใช้บ่อย:
git config --global alias.br branch # ช็อตคัตสำหรับ: git branch
git config --global alias.ci commit # ช็อตคัตสำหรับ: git commit
git config --global alias.co checkout # ช็อตคัตสำหรับ: git checkout
git config --global alias.graph "log --oneline --graph --all --decorate" # กราฟประวัติที่ดูสวยงาม
git config --global alias.last "log -1 HEAD" # แสดง commit ล่าสุด
git config --global alias.st status # ช็อตคัตสำหรับ: git status🚀 คำสั่ง Git ขั้นสูงสำหรับมืออาชีพ
คำสั่ง |
ตัวอย่าง |
คำอธิบาย |
|---|---|---|
git filter-repo |
เครื่องมือที่ทรงพลังและรวดเร็วในการเขียนประวัติ Git ใหม่ เพื่อลบหรือแก้ไขไฟล์ ผู้เขียน หรือ paths; แทนที่ git filter-branch ด้วยความเร็วและความปลอดภัยที่ดีกว่า | |
git filter-repo --path secret.txt --invert-paths |
เขียนประวัติใหม่เพื่อลบไฟล์หรือโฟลเดอร์ที่สำคัญอย่างมีประสิทธิภาพ ใช้ด้วยความระมัดระวัง |
|
git filter-repo --replace-text replacements.txt |
แทนที่ strings หรือ patterns แบบ bulk ทั้ง repo (เช่น ลบ credentials) |
|
git filter-repo --subdirectory-filter src |
แยกประวัติ subdirectory ออกเป็น repo ใหม่ โดยเก็บ metadata ของ commit |
|
git worktree |
จัดการ working directories หลายชุดที่ผูกกับ repo เดียว ทำงานบนหลาย branch ได้พร้อมกันโดยไม่ต้องโคลนใหม่ | |
git worktree add ../feature feature-branch |
สร้าง working tree เพิ่มเติมที่เชื่อมกับ repo เดียวกัน เพื่อ checkout branch ขนานกัน |
|
git worktree list |
แสดงรายการ worktrees ทั้งหมด เส้นทาง และ branch ที่เกี่ยวข้อง |
|
git worktree remove ../feature |
ลบ worktree ที่ไม่ใช้แล้วอย่างปลอดภัย |
|
git replace |
สร้าง reference ชั่วคราวเพื่อแทน objects ที่มีอยู่ ใช้ทดสอบหรือแก้ไขประวัติแบบไม่ทำลายข้อมูลจริง | |
git replace <old_commit> <new_commit> |
สลับ commit หนึ่งกับอีก commit ชั่วคราวใน local repo ใช้สำหรับทดสอบ |
|
git replace --list |
แสดง replacement refs ทั้งหมดที่กำลังใช้งาน |
|
git replace -d <replace_ref> |
ลบ replacement reference เพื่อคืนค่าพฤติกรรมเดิม |
|
git stash |
บันทึกการเปลี่ยนแปลงที่ยังไม่ commit ลง stack ชั่วคราว เพื่อให้สลับ context ได้โดยไม่ต้อง commit งานที่ยังไม่เสร็จ | |
git stash push -p |
เลือก stash เฉพาะบางส่วนของการเปลี่ยนแปลงแบบโต้ตอบ |
|
git stash push -m "WIP selective stash" |
สร้าง stash พร้อมข้อความอธิบาย |
|
git stash apply stash@{2} |
apply stash เฉพาะจากรายการ stash โดยไม่ลบมัน |
|
git rebase |
reapply commits บนฐานใหม่ เพื่อสร้างประวัติที่เป็นเส้นตรงและสะอาด พร้อมแก้ไขแบบ interactive | |
git rebase --interactive --autosquash |
เริ่ม rebase แบบ interactive พร้อม autosquash commits ที่ทำเครื่องหมายเป็น fixup/squash |
|
git rebase -i --autosquash HEAD~10 |
autosquash commits ก่อน push เพื่อประวัติที่สะอาด |
|
git commit --fixup <commit> |
สร้าง fixup commit สำหรับ autosquash ระหว่าง rebase |
|
git commit --squash <commit> |
สร้าง squash commit เพื่อรวมกับ commit ที่เลือกใน rebase |
|
git bisect |
เครื่องมือ binary search เพื่อหาว่า commit ไหนนำ bug เข้ามาอย่างมีประสิทธิภาพ | |
git bisect run |
ทำ bisect อัตโนมัติด้วย script ทดสอบในแต่ละ commit เพื่อหาต้นเหตุของ bug |
|
git bisect start; git bisect bad; git bisect good v1.0; git bisect run ./test.sh |
รัน test script ระหว่าง bisect เพื่อเร่งการหา commit ที่ผิดพลาด |
|
git bisect visualize |
เปิดเครื่องมือกราฟิกเพื่อติดตามกระบวนการ bisect |
|
git bisect reset |
ออกจากโหมด bisect และกลับสู่ HEAD เดิม |
|
git commit |
บันทึกการเปลี่ยนแปลงพร้อมตัวเลือกขั้นสูง เช่น amend, sign, fixup, และการปรับแต่งข้อความ เพื่อประวัติคุณภาพสูง | |
git commit --gpg-sign |
สร้าง commit ที่เซ็นด้วยกุญแจ GPG ของคุณเพื่อยืนยันผู้เขียนและความถูกต้อง |
|
git commit -S -m "Signed commit" |
เซ็น commit ทั้งหมดด้วยกุญแจ GPG เพื่อยืนยันความถูกต้อง |
|
git config --global user.signingkey <key_id> |
ตั้งค่ากุญแจ GPG ที่ใช้เซ็น commits แบบ global |
|
git log --show-signature |
ตรวจสอบและแสดงข้อมูลลายเซ็น GPG ของ commits |
|
git reflog |
เก็บ log ของการอัปเดต HEAD และ branches สำคัญต่อการกู้ commit ที่หายไปและติดตามประวัติในเครื่อง | |
git reset --hard HEAD@{3} |
รีเซ็ต branch ปัจจุบันไปยังสถานะก่อนหน้าโดยใช้ reflog |
|
git reflog expire --expire=now --all |
หมดอายุ entries ของ reflog ทันที (ใช้ด้วยความระมัดระวัง) |
🧰 เคล็ดลับ Workflow สำหรับมืออาชีพและระบบอัตโนมัติ
หัวข้อ |
คำสั่ง / ตัวอย่าง |
คำอธิบาย & เคล็ดลับ |
|---|---|---|
การทำความสะอาด Repo แบบเข้มข้น |
git gc --aggressive --prune=now |
ทำ garbage collection และ prune objects ที่ไม่สามารถเข้าถึงได้ทันที ใช้สำหรับช่วงบำรุงรักษา |
Worktrees สำหรับ branch ขนาน |
git worktree add ../feature-branch feature |
เก็บ working trees หลายชุดเพื่อพัฒนาฟีเจอร์พร้อมกัน ลด overhead ของการโคลน |
ประวัติที่สะอาดและเป็นเส้นตรง |
git rebase -i --autosquash |
ก่อน push ให้ rebase แบบ interactive พร้อม autosquash เพื่อรักษาประวัติให้อ่านง่าย |
Commits ที่ปลอดภัย |
git commit -S |
เซ็น commits ด้วย GPG เพื่อเพิ่มความน่าเชื่อถือ (จำเป็นในหลายองค์กร) |
การ bisect อัตโนมัติ |
git bisect run ./test-script.sh |
รัน test script อัตโนมัติระหว่าง bisect เพื่อหา commit ที่ผิดพลาด |
แคชการแก้ Conflict |
git config --global rerere.enabled true |
เปิดใช้งานการ reuse วิธีแก้ conflict เพื่อประหยัดเวลาเมื่อ rebase หรือ merge |
Aliases และ Hooks ร่วมกัน |
เก็บ aliases และ commit hooks ไว้ใน repo ร่วม หรือ CI pipeline เพื่อกำหนดมาตรฐานทีมและเพิ่ม productivity |
แหล่งข้อมูลเพิ่มเติม
🧠 เคล็ดลับ
อย่าพยายามจำทุกอย่าง ใช้ --help สำรวจ และฝึกฝนบ่อย ๆ:
git help <command>
git status🌐 ลิงก์ที่มีประโยชน์
📘 เอกสาร Git อย่างเป็นทางการ — คู่มือรายละเอียดของทุกคำสั่ง Git:
https://git-scm.com/docs
📙 Learn Git Branching — บทเรียน interactive แบบ visualization สำหรับการเข้าใจ branching:
https://learngitbranching.js.org
📕 Pro Git book (ฟรี โดย Scott Chacon & Ben Straub):
https://git-scm.com/book
📗 Git Cheatsheet (สรุปอ้างอิงอย่างเป็นทางการ):
https://education.github.com/git-cheat-sheet-education.pdf