---
title: "建立你自己的 git 指令（alias）"
description: "有沒有想過縮短 git 指令？你當然可以用 shell alias，但你得一直記著前後脈絡，才不會忘記每個 alias 代表什麼。其實你可以用 alias 在 git 裡定義自己的…"
canonical: https://oozou.com/til/create-your-own-git-commands-aliases-15
locale: zh-Hant
date: 2020-10-13
topic: shell
---

# 建立你自己的 git 指令（alias）

> 有沒有想過縮短 git 指令？你當然可以用 shell alias，但你得一直記著前後脈絡，才不會忘記每個 alias 代表什麼。其實你可以用 alias 在 git 裡定義自己的…

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

有沒有想過縮短 git 指令？你當然可以用 shell alias，但你得一直記著前後脈絡，才不會忘記每個 alias 代表什麼。其實你可以用 alias 在 git 裡定義自己的指令。

```shell
git config --global alias.<handle> <command> 
```

舉個例子；我懶得打 *git status*，所以想把它縮短成 *git s*

```shell
git config --global alias.s status
```

就這樣，現在你只要輸入 *git s* 就能取得目前 repository 的狀態。

---

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

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