1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Gitのエイリアスおすすめ設定10選!コマンド短縮で作業効率化(Mac編)

Last updated at Posted at 2025-03-03

はじめに

Gitを使っていると、毎回長いコマンドを入力するのが面倒になることはありませんか?
そこで便利なのが Gitエイリアス です!

本記事では、エイリアスの設定方法とオススメのエイリアス10選を紹介します。

本記事はmacユーザ向けです

1. Gitエイリアスとは?

Gitエイリアスとは、よく使うGitコマンドを短縮して入力しやすくする設定 です。

例えば、git statusgit s に設定すれば、少ないキー入力で操作できるようになります。

# 通常のGitコマンド
$ git status

# エイリアスを設定すると...
$ git s

2. エイリアスを設定する方法

~/.zshrc を編集

ターミナルで下記のコマンドを入力

open ~/.zshrc

ファイルが開けたら、以下のようにコードを追加または編集してください。

s = status
co = checkout
br = branch
cm = commit -m
lg = log --oneline --graph --decorate --all

編集完了後保存を行い、ターミナルで下記コマンドを入力してエイリアス設定は完了です。

source ~/.zshrc

コマンド打ち込んでも設定が反映されていない場合は、エディタの再起動を試してみてください。

3. オススメのエイリアス設定10選

ここでは、おすすめのエイリアス設定10選をご紹介します。

コマンド エイリアス 説明
git status git s 作業ツリーの状態を確認
git checkout <branch_name> git co <branch_name> 指定したブランチに切り替え (branch_name はブランチ名に置き換え)
git commit -m "message" git cm "message" コミットの簡略化
git branch git br ブランチ一覧の表示
git log --oneline --graph --decorate --all git lg 視覚的にログを表示
git diff git df 変更内容を確認
git pull origin <branch_name> git pl <branch_name> リモートリポジトリから指定したブランチを取得
git push origin <branch_name> git ps <branch_name> ローカルのブランチをリモートリポジトリの指定したブランチに反映させる
git reset --hard git rh コミットや変更をリセット
git stash git st 変更を一時的に退避

これらのエイリアスを設定するだけで、Gitのコマンド入力が格段に速くなります。

4. まとめ

Gitエイリアスを活用すると、作業がスムーズになり、入力ミスも減ります。
少しの設定で開発効率が大幅に向上するので、ぜひ試してみてください!

1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?