---
title: "ใช้ฟีเจอร์ alias ของ Git"
description: "Git ให้คุณสร้าง alias ได้ในตัวผ่าน config โดย config แบบ global ควรอยู่ที่ ~/.gitconfig"
canonical: https://oozou.com/til/using-git-s-aliases-feature-61
locale: th
date: 2020-10-13
topic: shell
---

# ใช้ฟีเจอร์ alias ของ Git

> Git ให้คุณสร้าง alias ได้ในตัวผ่าน config โดย config แบบ global ควรอยู่ที่ ~/.gitconfig

Published: 2020-10-13 · Topic: [shell](https://oozou.com/th/til-topics/shell) ([markdown](https://oozou.com/th/til-topics/shell.md))

Git ให้คุณสร้าง alias ได้ในตัวผ่าน config โดย config แบบ global ควรอยู่ที่ *~/.gitconfig*

```git
[alias]
  aliases = !git config --get-regexp 'alias.*' | colrm 1 6 | sed 's/[ ]/ = /' | sort
  count = shortlog -sn
  l = log
  co = checkout
  ca = commit -C HEAD --amend
  c  = commit
  cm = commit -m
  a  = add
  s  = status
  b  = branch
  p  = push
  mt = mergetool
  dt = difftool
  o  = origin
  rc = rebase --continue
  rs = rebase --skip
  pd  = !git checkout develop && git pull origin develop && git branch --merged | grep -v '*' | grep -v 'master' | xargs git branch -d && git fetch --prune origin
  pm  = !git checkout master && git pull origin master && git branch --merged | grep -v '*' | grep -v 'develop' | xargs git branch -d && git fetch --prune origin
  pr = pull-request -c -m
```

ส่วนใหญ่ก็เข้าใจได้จากชื่อเลย...

*git pd* (prune develop) - checkout ไปที่ develop ดึงการเปลี่ยนแปลงล่าสุด ลบ branch ค้างเก่าทั้งหมดยกเว้น develop (จะลบ master ด้วย)

*git pm* (prune master) - ทำแบบเดียวกับ prune develop แต่สำหรับ master

---

Contact OOZOU: hello@oozou.com · +66 2544 0000 · https://oozou.com/th/contact

More for AI agents: https://oozou.com/llms.txt · every page has a markdown twin at its URL plus ".md"
