ชีตสรุป Git
เอกสารอ้างอิง Git ที่ค้นหาและพิมพ์ได้——การตั้งค่า, branch, การ merge, การ rebase, remote, การ stash, tag และการย้อนการเปลี่ยนแปลง ฟรี
Setup & config
10git config --global user.name "Jane Doe"
git config --global user.email "jane@example.com"
git config --global init.defaultBranch main
git config --global core.editor "code --wait"
git config --global pull.rebase true
git config --global alias.co checkout
git config --global --list
git config user.email
git config --global color.ui auto
git help <command>
Create & clone repos
9git init
git init my-project
git clone https://example.com/repo.git
git clone git@example.com:user/repo.git
git clone <url> my-dir
git clone --depth 1 <url>
git clone --branch dev <url>
git clone --recurse-submodules <url>
git remote add origin <url>
Staging & committing
11git add file.txt
git add .
git add -A
git add -p
git commit -m "Add login form"
git commit -am "Fix typo"
git commit --amend
git commit --amend --no-edit
git rm file.txt
git mv old.txt new.txt
git reset file.txt
Branches
10git branch
git branch -a
git switch -c feature/login
git switch main
git checkout -b hotfix
git branch -m old-name new-name
git branch -d feature/login
git branch -D feature/login
git push origin --delete feature/login
git switch -
Merging & rebasing
10git merge feature/login
git merge --no-ff feature/login
git merge --squash feature/login
git merge --abort
git rebase main
git rebase -i HEAD~3
git rebase --continue
git rebase --abort
git cherry-pick <hash>
git mergetool
Remotes & syncing
11git remote -v
git remote add upstream <url>
git remote set-url origin <url>
git fetch
git fetch --all --prune
git pull
git pull --rebase
git push
git push -u origin main
git push --force-with-lease
git push origin --tags
Inspecting & comparing
10git status
git status -s
git diff
git diff --staged
git diff main..feature
git diff HEAD~1 HEAD
git show <hash>
git show HEAD:file.txt
git log --stat
git shortlog -sn
Undoing changes
10git restore file.txt
git restore --staged file.txt
git restore --source=HEAD~1 file.txt
git checkout -- file.txt
git reset --soft HEAD~1
git reset --mixed HEAD~1
git reset --hard HEAD~1
git revert <hash>
git clean -fd
git clean -nd
Stashing
10git stash
git stash push -m "wip"
git stash -u
git stash list
git stash show -p
git stash apply
git stash pop
git stash apply stash@{2}
git stash drop stash@{0}
git stash clear
Tags
9git tag
git tag v1.0.0
git tag -a v1.0.0 -m "Release 1.0.0"
git tag -a v1.0.0 <hash>
git show v1.0.0
git push origin v1.0.0
git push origin --tags
git tag -d v1.0.0
git push origin --delete v1.0.0
Logs & history
12git log
git log --oneline
git log --oneline --graph --all
git log -p
git log --author="Jane"
git log --since="2 weeks ago"
git log --pretty=format:"%h %an %s"
git blame file.txt
git reflog
git bisect start
git bisect good <hash>
git bisect bad
ไม่มีรายการที่ตรงกับ “:q”
เกี่ยวกับ ชีตสรุป Git
ชีทสรุปคำสั่ง Git นี้จัดระเบียบการควบคุมเวอร์ชันตามงาน: การตั้งค่าและกำหนดค่า การสร้างและโคลนที่เก็บ การ stage และ commit branch การ merge และ rebase remote และการซิงค์ การตรวจสอบและเปรียบเทียบ การยกเลิกการเปลี่ยนแปลง การ stash แท็ก รวมถึง log และประวัติ
หมวดต่าง ๆ สะท้อนวิธีที่คำถาม Git มักเกิดขึ้นจริง — "จะยกเลิกสิ่งนี้ยังไง?", "จะย้าย branch นี้ยังไง?", "อะไรเปลี่ยนแปลงระหว่าง commit เหล่านี้?" — ดังนั้นคำสั่งที่คุณต้องการจะอยู่ใกล้กับรูปแบบต่าง ๆ ของมัน แต่ละอย่างมีคำอธิบายสั้น ๆ ว่าทำอะไรและใช้เมื่อไหร่
ชีทนี้ฟรีและทำงานฝั่งไคลเอนต์ทั้งหมด กรองทุกคำสั่งแบบเรียลไทม์ด้วยช่องค้นหา กระโดดระหว่างหมวดจากสารบัญแบบ sticky คัดลอกคำสั่งใด ๆ ด้วยคลิกเดียว และพิมพ์หน้านี้ออกมา — เฉพาะหมวดยกเลิกการเปลี่ยนแปลงก็คุ้มค่าที่จะติดไว้บนผนังแล้ว
วิธีใช้ ชีตสรุป Git
- ไล่ดูสิบเอ็ดหมวด ตั้งแต่ Setup & config ผ่าน Undoing changes ไปจนถึง Logs & history
- ค้นหางานอย่าง rebase, stash หรือ amend เพื่อกรองคำสั่งแบบเรียลไทม์
- กระโดดไปยังหมวดอย่าง Remotes & syncing ผ่านแถบข้าง sticky sidebar
- คลิกคำสั่งหรือไอคอนคัดลอกเพื่อคัดลอก แล้วปรับชื่อ branch หรือ remote ก่อนรัน
- พิมพ์ชีทนี้ไว้เป็นเอกสารอ้างอิง Git แบบออฟไลน์