🧞
あなたの知らないGitのコマンド
Gitのrootを取得する
git rev-parse --show-toplevel
親Gitのrootを取得する(サブモジュール)
サブモジュールのディレクトリで、親リポジトリのディレクトリを取得する
git rev-parse --show-superproject-working-tree
現在(HEAD)のブランチ名を取得する
git rev-parse --abbrev-ref HEAD
ベアリポジトリのデフォルトブランチを変更する
HEADに書いてあるブランチがデフォルトになる。
git symbolic-ref HEAD refs/heads/<既存のブランチ名>
まだpushされてないブランチなら新規に作成する。
git branch -m <ブランチ名>
全てのリポジトリィに同じGit hooksを設定する
git config --global core.hooksPath <ファイルパス>
~/.gitconfigに追記される
~/.gitconfig
[core]
hooksPath = <ファイルパス>
Git hooksの設定をリポジトリィ内に含める
- リポジトリィ内に
assets/git/hooks/
ディレクトリィを作成しコミットする。 - リポジトリィをクローンしたら、次のコマンドを実行する。
git config core.hooksPath assets/git/hooks/
Git hooksが設定されているディレクトリィを取得する
git config core.hooksPath
Gitの認証情報をキーチェーンに保存する
git config --global credential.helper osxkeychain
Discussion