🖥

Git 操作の速度を上げる .gitconfig のエイリアス (秘伝のタレ)

2024/01/02に公開

.gitconfig

[alias]
  # 普通のエイリアス
  ck = checkout
  br = branch
  st = status -s
  cm = commit

  # 現在のブランチを返す
  # 他のgitエイリアスに組み込むためのエイリアスで、直接は利用しない
  current = !git symbolic-ref --short HEAD

  # いまの作業状態で、てきとうなコミット名でコミットする
  # コミット名を考えたくない時に使う
  update = !git add . && git commit -m "update"

  # なにも変更差分がない状態でコミットを作ってpushする
  pr = "!sh -c 'git checkout -b $1 && git commit --allow-empty -m $1 && git push' -"

  # 今の作業内容で新規コミットを作る ( add + commit )
  create = !git add . && git commit
  cr = !git create

  # 今の作業内容をammendして反映する ( add + commit --amend )
  forget = !git add . && git commit --amend
  fg = !git forget

  # 現在のコミットを壊してコミット未反映状態にする
  break = reset HEAD^

  # コミットされていないものはすべて消す
  vanish = !git reset . && git checkout . && git clean -fd

  # rebaseでもmergeでもcherry-pickでもabortする
  abort = !git rebase --abort || git merge --abort | git cherry-pick --abort

  # rebaseの時の変更を反映する
  change = !git add . && git rebase --continue

  # 現在ブランチをリモート(origin)からpullする
  pull-from-origin = !git pull origin $(git current)

  po = pull-from-origin

  # 現在ブランチをリモート(origin)の最新の状態に書き換える
  reset-current = !git fetch && git reset --hard origin/$(git current)

  # localで現在のブランチ以外を全て削除する
  delete-branches = !git branch | xargs git branch -D

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ

Twitter

https://twitter.com/YumaInaura

公開日時

2023-12-06

Discussion