Skip to content

Instantly share code, notes, and snippets.

@hushin
Last active May 6, 2023 14:33
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hushin/906eaa916c696463eaf7a2cff7ff7daf to your computer and use it in GitHub Desktop.
Save hushin/906eaa916c696463eaf7a2cff7ff7daf to your computer and use it in GitHub Desktop.
ghq フォルダ整理

ghq フォルダ整理

ghq でリポジトリ管理していて、フォルダ整理したくなったので調べながら書いたコマンド集

そもそもgit管理してないフォルダを見つける

ghq root/github.com/hoge/fuga のような階層になっていること前提

cd $(ghq root)
find . -type d -maxdepth 3 -mindepth 3 | xargs -I@ bash -c '[ -e @/.git ] || echo @'

uncommitted, untracked, unpushed がないか調べる

ググったら良さそうなツールがあった

fboender/multi-git-status: Show uncommitted, untracked and unpushed changes for multiple Git repos

ghq get fboender/multi-git-status
cd $(ghq root)
github.com/fboender/multi-git-status/mgitstatus -d 3

一括アップデート

https://leanpub.com/ghq-handbook を読んで勉強になった。

ghq list | ghq get --update --parallel

git 管理していないものを消したい

-n は確認用。問題なさそうなら -f にして実行

untracked なファイルを削除

ghq list --full-path --vcs=git | xargs -I@ bash -c 'echo @ && git -C @ clean -d -n'

.gitignore で無視しているファイル・フォルダのみ対象にする。 node_modules とか dist とか。

ghq list --full-path --vcs=git | xargs -I@ bash -c 'echo @ && git -C @ clean -X -d -n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment