Upgrade to Pro — share decks privately, control downloads, hide ads and more …

What I've tried to simplify Git operations

What I've tried to simplify Git operations

Git操作を楽にするためにやってきたこと
@社内LT会 2024-07-31

Avatar for kiharito

kiharito

August 01, 2024
Tweet

Other Decks in Programming

Transcript

  1. Tabิ׬ $ git checko<Tab> $ git checkout ——— $ git

    checkout deve<Tab> develop/sample1 develop/sample2 git-completionΛಋೖ ϒϥϯν໊ͷิ׬΋ޮ͘
  2. ϓϩϯϓτ sample-web on dev [!] $ git add . sample-web

    on dev [+] $ git commit -m message [dev 1a2b3c4] message 1 file changed, 50 insertions(+) create mode 100644 openapi.yaml sample-web on dev [↑] $ git push sample-web on dev $ git checkout main sample-web on main $ git-promptͰλʔϛφϧͷ ϓϩϯϓτʹGitؔ࿈ͷ৘ใ Λදࣔͤ͞Δ starship΍ݩ͔Βද͕ࣔ͋Δ λʔϛφϧΛ࢖͏ͷ΋͋Γ
  3. Git ΤΠϦΞε $ git co . git: 'co' is not

    a git command. See 'git --help'. The most similar commands are commit clone log $ git config --global alias.co checkout $ git co . Updated 3 paths from the index GitίϚϯυʹΤΠϦΞεΛ ొ࿥Ͱ͖Δ GitΤΠϦΞε͚ͩͰ͸`git ` ͷೖྗ͸ল͚ͳ͍
  4. Zsh ΤΠϦΞε # ~/.zshrc alias gco=“git checkout” alias gbr=“git branch”

    ——— $ source ~/.zshrc $ gco . Updated 3 paths from the index `git`΋লུͰ͖Δ ଞͷίϚϯυͱॏෳ͠ͳ͍ Α͏஫ҙ͕ඞཁ
  5. Zsh ΤΠϦΞε $ brew install gum ——— # ~/.zshrc alias

    gbrD=“git branch | cut -c 3- | gum choose --no-limit | xargs git branch -D” ——— $ gbrD | Choose: | > - master | - develop/qdev/sample | - spike/fastapi ڽͬͨ͜ͱ΋࣮ݱՄೳ ޻෉࣍ୈͰ͸λʔϛφϧ্ ͰΤΠϦΞεΛల։Ͱ͖Δ →ଞͷਓ΋த਎͕Θ͔Δ
  6. Zsh ؔ਺ $ brew install fzf ——— # ~/.zshrc fgco()

    { local branches branches=$(git branch --all | rg -v HEAD | cut -c 3- | sed "s#remotes/[^/]*/ ##" | awk '!a[$0]++{print}') && echo $branches | fzf | xargs git checkout } ——— $ fgco ΤΠϦΞεΛ͞ΒʹϨϕϧ Ξοϓͤͨ͞΋ͷ͕࡞ΕΔ
  7. ঺հͨ͠πʔϧ Gum A tool for glamorous shell scripts 🎀 fzf

    🌸 A command-line fuzzy fi nder Lazygit simple terminal UI for git commands starship ☄🌌 The minimal, blazing-fast, and in fi nitely customizable prompt for any shell!