Gitの設定

筆者の現在の設定

credential.helper=osxkeychain
user.name=Usagi
user.email=Usagi@gmail.com
core.excludesfile=/Users/Usagi/.gitignore_global
difftool.sourcetree.cmd=opendiff "$LOCAL" "$REMOTE"
difftool.sourcetree.path=
mergetool.sourcetree.cmd=/Applications/Sourcetree.app/Contents/Resources/opendiff-w.sh "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED"
mergetool.sourcetree.trustexitcode=true
commit.template=/Users/Usagi/.stCommitMsg
safe.barerepository=explicit
init.defaultbranch=main

gitの設定を確認する

git config --list

上記を実行すると以下のように現在の設定値が表示されます。

credential.helper=×××××××
user.name=××××××
user.email=××××××@gmail.com
core.excludesfile=/Users/×××××/.gitignore_global
difftool.sourcetree.cmd=opendiff “$LOCAL” “$REMOTE”
difftool.sourcetree.path=
mergetool.sourcetree.cmd=/Applications/Sourcetree.app/Contents/Resources/opendiff-w.sh “$LOCAL” “$REMOTE” -ancestor “$BASE” -merge “$MERGED”
mergetool.sourcetree.trustexitcode=true
commit.template=/Users/harukaomura/.stCommitMsg
safe.barerepository=explicit

特定の設定値を確認するには・・・

git config user.name

設定

名前の設定

git config --global user.name 名前

git config・・・git configコマンド

–global・・・オプション

user.name・・・設定項目

value・・・設定値

メールアドレスの設定

git config --global user.email メールアドレス

エディタをvscodeに設定

vscodeで開く場合

git config --global core.editor "code --wait"

何も設定しない場合、viエディタが使われる。

他のエディタを使用する場合

以下リンクにすべて記載されているので見てみてください。

https://git-scm.com/book/en/v2/Appendix-C:-Git-Commands-Setup-and-Config.html#ch_core_editor

設定確認

git config core.editor

デフォルトブランチをmainにする

git config --global init.defaultBranch main

設定確認

git config init.defaultBranch

設定削除

 git config --global --unset 設定項目名

参考