LoginSignup
0
0

More than 1 year has passed since last update.

【Git】.gitconfigについて

Last updated at Posted at 2022-05-26

.gitconfigの内容

~/.gitconfig
[alias]
  st = status
  df = diff
  co = commit
  br = branch
  ps = push
  pl = pull
  ck = checkout
  graph = log --pretty=format:'%Cgreen[%cd] %Cblue%h %Cred<%cn> %Creset%s' --date=short  --decorate --graph --branches --tags --remotes
  diffw = diff --word-diff

[core]
  quotepath  = false
  ignorecase = false
  editor = code --wait --new-window

[diff]
  tool = vscode
[difftool "vscode"]
  cmd = code --wait --new-window --diff $LOCAL $REMOTE

[user]
  email = example@email.jp
  name = UserName

[init]
  defaultBranch = main

[merge]
  tool = vscode
[mergetool "vscode"]
  cmd = code --wait --new-window $MERGED

[pull]
  ff = only 

[push]
  default = current

各設定について

alias

コマンドのエイリアスを設定します。
ターミナルからコマンドを実行して設定する場合には以下のようにします。

ターミナル
$ git config --global alias.st status

core

quotepath

日本語のファイル名をエンコードするか否かを設定できます。
falseに設定すると以下のように普通に日本語が表示されます。

$ git status
Changes not staged for commit:
    modified:   サンプル.md

ignorecase

ファイルの名の大文字と小文字を区別するか否かを設定できます。
デフォルトでは区別しません。
falseにすることで区別するようになります。

editor

エディタを設定します。
以下のようにすることでコミットやマージなどの際に使用するエディタをVScodeにすることができます。

~/.gitconfig
[core]
    editor = code --wait
[diff]
    tool = vscode
[difftool "vscode"]
    cmd = code --wait --diff $LOCAL $REMOTE
[merge]
    tool = vscode
[mergetool "vscode"]
    cmd = code --wait $MERGED

diff

editor参照

user

git logなどで表示されるユーザー名やメールアドレスを設定します。

init defaultBranch

デフォルトのブランチ名を設定します。

merge

editor参照

pull ff

pullした際にmerge commitを作成するか設定します。
以下から選択可能です。

動作
デフォルト fast-forwardな場合はmergeし、それ以外はmerge commitを作成。git pull --ffと同じ。
only fast-forwardな場合はmergeし、それ以外はエラー。git pull --ff-onlyと同じ。
false 常にmerge commitを作成。git pull --no-ffと同じ。

push default

push時の動作を設定します。

動作
nothing 常にどこにpushするか指定。
matching ローカルとリモートで同じ名前のリポジトリにpush。
upstream upstream branchが現在のブランチに設定されている場合push。
simple upstream branchが現在のブランチに設定されており、ブランチ名が同じ場合pushする。デフォルト。
current 現在のブランチをリモートに同じ名前でpush。
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0