gitconfig

[user]
    name = Yasushi Sakai
    email = yasushi.accounts@fastmail.com
[core]
    excludesfile = /Users/yasushi/.gitignore_global
    editor = nvim --cmd 'let g:unception_block_while_host_edits=1'
[pull]
    rebase = true
[filter "lfs"]
    clean = git-lfs clean -- %f
    smudge = git-lfs smudge -- %f
    process = git-lfs filter-process
    required = true
[sequence]
    editor = interactive-rebase-tool
[interactive-rebase-tool]
    inputMoveDown = j
    inputMoveUp = k
    inputMoveSelectionDown = Down
    inputMoveSelectionUp = Up
    inputShowCommit = l
[format]
    pretty = format:%C(auto,yellow)%h %C(auto,blue)%>(17)%ah %C(auto,red)% gD% D %C(auto,reset)%s

[alias]
    s  = status -sbu
    r  = rebase -i HEAD~15
    st = stash
    sta= stash apply
    l  = log
    n  = log -1 HEAD -stat
    p  = pull
    c  = commit
    cm = commit -m
  • nvim が変なのは、vim の中の terminal で git commit なんかをした時に、git をブロック(待ち状態)にしておくため。 git rebase -i もこの設定を見にいくみたい。
  • interactive-rebase-tool はコミットの履歴を綺麗にする時に使うもの。矢印上下でコミットの移動だから注意。

    git rebase -i HEAD~10 で、10 個前の commit から編集可能。(当然サーバーとの齟齬があるなら要 --force)

gitui

lazygit よりも早くて、小さくて、rust だけど機能が少ないので様子見。

https://github.com/extrawurst/gitui

curl https://raw.githubusercontent.com/extrawurst/gitui/master/vim_style_key_config.ron -o ~/.config/gitui/key_bindings.ron

lazygit

brew install lazygit
os:
  editPreset: 'nvim'
  editInTerminal: true
gui:
  showIcons: true

github api

the personal access token (PAT) written below have been invalidated.

list repos

PAT=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
curl -H "Authorization: Bearer $PAT" \
     -H "Accept: application/vnd.github+json" \
     -H "X-GitHub-Api-Version: 2022-11-28" \
     --url "https://api.github.com/user/repos?per_page=100&affiliation=owner" \
     | jq '.[] | .full_name' | sed 's/"//g' >> ~/repos.txt

clone all repos

cd archive
cat ~/repos.txt | xargs -I{} git clone git@github.com:{}

delete a repo

PAT=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
REPO=yasushisakai/submo
curl -X DELETE \
     -H "Authorization: Bearer $PAT" \
     -H "Accept: application/vnd.github+json" \
     -H "X-GitHub-Api-Version: 2022-11-28" \
     --url "https://api.github.com/repos/$REPO"

bulk remove

use with caution:

cat repos_to_delete.txt | sed 's/"//g' | awk '{print "https://api.github.com/repos/"$1}' | xargs curl -X DELETE -H "Authorization: Bearer $PAT" -H "X-Github-Api-Version: 2022-11-28"

Date: 2023-02-20 Mon 13:16