gitコマンドの使い方 ~ git config ~
目次
git config コマンドの概要
gitには数百種類の設定項目がありますが、ポイントは図の通り設定ファイルが3つ箇所にあり上に設定されているほど優先度が高くなります。
file-option | 適用範囲 | 設定ファイルの場所 |
---|---|---|
–local | リポジトリ単位 | [repository-dir]/.git/config |
–global | ユーザ単位 | [user-home-dir]/.gitconfig |
–system | 全ユーザ共通 | [git-install-dir]/etc/gitconfig |
つまり、設定値の参照順序はこうなります。
git config コマンドの使い方
設定値の確認
設定値を一覧で確認する場合
git config [file-option] --list
特定の設定項目の設定値を確認する場合
git config [file-option] 設定項目
[file-option]には[–local][–global][–system]のいずれかを設定しますが、省略した場合は有効になっている設定値が表示されます。
設定値の登録・更新
git config [file-option] 設定項目 設定値
設定値の削除
git config [file-option] --unset 設定項目
git config オプション
利用頻度の高い初期設定しておくと便利な設定項目です。
設定項目 | 意味 |
---|---|
user.name | ユーザ名を設定する(設定必須) |
user.email | メールアドレスを設定する(設定必須) |
core.ignorecase | falseを設定するとファイル名の大文字と小文字を区別する |
core.quotepath | falseを設定すると日本語が文字化けしない |
core.pager | 文字コードを指定する |
core.autocrlf | falseを設定するとcommitやcheckout時に改行コードの自動変換機能がOFFになる |
http.proxy | プロキシサーバを利用する際に設定 |
git config 設定例
git config --global user.name "snow"
git config --global user.email snow@abc.com
git config --global core.ignorecase false
git config --global core.quotepath false
git config --global core.pager "LESSCHARSET=utf-8 less"
git config --global core.autocrlf false
git config --global http.proxy http://proxy.abc.com:8080
git config の全てのオプションを確認する方法
以下のコマンドを実行するとブラウザでgit configのヘルプが表示され、各設定の意味を確認することができます。
git config --help
設定項目は全部列挙するとこれだけあります。
気になる設定値を調べてみてgitを利用しやすいようにカスタマイズしていきましょう。
core.fileMode
core.hideDotFiles
core.ignoreCase
core.precomposeUnicode
core.protectHFS
core.protectNTFS
core.fsmonitor
core.trustctime
core.splitIndex
core.untrackedCache
core.checkStat
core.quotePath
core.eol
core.safecrlf
core.autocrlf
core.checkRoundtripEncoding
core.symlinks
core.gitProxy
core.sshCommand
core.ignoreStat
core.preferSymlinkRefs
core.alternateRefsCommand
core.alternateRefsPrefixes
core.bare
core.worktree
core.logAllRefUpdates
core.repositoryFormatVersion
core.sharedRepository
core.warnAmbiguousRefs
core.compression
core.looseCompression
core.packedGitWindowSize
core.packedGitLimit
core.deltaBaseCacheLimit
core.bigFileThreshold
core.excludesFile
core.askPass
core.attributesFile
core.hooksPath
core.editor
core.commentChar
core.filesRefLockTimeout
core.packedRefsTimeout
core.pager
core.whitespace
core.fsyncObjectFiles
core.preloadIndex
core.fscache
core.longpaths
core.unsetenvvars
core.restrictinheritedhandles
core.createObject
core.notesRef
core.commitGraph
core.useReplaceRefs
core.multiPackIndex
core.sparseCheckout
core.sparseCheckoutCone
core.abbrev
add.ignoreErrors
add.ignore-errors
add.interactive.useBuiltin
am.keepcr
am.threeWay
apply.ignoreWhitespace
apply.whitespace
blame.blankBoundary
blame.coloring
blame.date
blame.showEmail
blame.showRoot
blame.ignoreRevsFile
blame.markUnblamables
blame.markIgnoredLines
branch.autoSetupMerge
branch.autoSetupRebase
branch.sort
branch.<name>.remote
branch.<name>.pushRemote
branch.<name>.merge
branch.<name>.mergeOptions
branch.<name>.rebase
branch.<name>.description
browser.<tool>.cmd
browser.<tool>.path
checkout.defaultRemote
clean.requireForce
color.advice
color.advice.hint
color.blame.highlightRecent
color.blame.repeatedLines
color.branch
color.branch.<slot>
color.diff
color.diff.<slot>
color.decorate.<slot>
color.grep
color.grep.<slot>
color.interactive
color.interactive.<slot>
color.pager
color.push
color.push.error
color.remote
color.remote.<slot>
color.showBranch
color.status
color.status.<slot>
color.transport
color.transport.rejected
color.ui
column.ui
column.branch
column.clean
column.status
column.tag
commit.cleanup
commit.gpgSign
commit.status
commit.template
commit.verbose
credential.helper
credential.useHttpPath
credential.username
credential.<url>.*
credentialCache.ignoreSIGHUP
completion.commands
diff.autoRefreshIndex
diff.dirstat
diff.statGraphWidth
diff.context
diff.interHunkContext
diff.external
diff.ignoreSubmodules
diff.mnemonicPrefix
diff.noprefix
diff.orderFile
diff.renameLimit
diff.renames
diff.suppressBlankEmpty
diff.submodule
diff.wordRegex
diff.<driver>.command
diff.<driver>.xfuncname
diff.<driver>.binary
diff.<driver>.textconv
diff.<driver>.wordRegex
diff.<driver>.cachetextconv
diff.tool
diff.guitool
diff.indentHeuristic
diff.algorithm
diff.wsErrorHighlight
diff.colorMoved
diff.colorMovedWS
difftool.<tool>.path
difftool.<tool>.cmd
difftool.prompt
fastimport.unpackLimit
feature.*
feature.experimental
feature.manyFiles
fetch.recurseSubmodules
fetch.fsckObjects
fetch.fsck.<msg-id>
fetch.fsck.skipList
fetch.unpackLimit
fetch.prune
fetch.pruneTags
fetch.output
fetch.negotiationAlgorithm
fetch.showForcedUpdates
fetch.parallel
fetch.writeCommitGraph
format.attach
format.from
format.numbered
format.headers
format.to
format.cc
format.subjectPrefix
format.coverFromDescription
format.signature
format.signatureFile
format.suffix
format.pretty
format.thread
format.signOff
format.coverLetter
format.outputDirectory
format.useAutoBase
format.notes
filter.<driver>.clean
filter.<driver>.smudge
fsck.<msg-id>
fsck.skipList
gc.aggressiveDepth
gc.aggressiveWindow
gc.auto
gc.autoPackLimit
gc.autoDetach
gc.bigPackThreshold
gc.writeCommitGraph
gc.logExpiry
gc.packRefs
gc.pruneExpire
gc.worktreePruneExpire
gc.reflogExpire
gc.<pattern>.reflogExpire
gc.reflogExpireUnreachable
gc.<pattern>.reflogExpireUnreachable
gc.rerereResolved
gc.rerereUnresolved
gitcvs.commitMsgAnnotation
gitcvs.enabled
gitcvs.logFile
gitcvs.usecrlfattr
gitcvs.allBinary
gitcvs.dbName
gitcvs.dbDriver
gitcvs.dbUser, gitcvs.dbPass
gitcvs.dbTableNamePrefix
gitweb.category
gitweb.description
gitweb.owner
gitweb.url
gitweb.avatar
gitweb.blame
gitweb.grep
gitweb.highlight
gitweb.patches
gitweb.pickaxe
gitweb.remote_heads
gitweb.showSizes
gitweb.snapshot
grep.lineNumber
grep.column
grep.patternType
grep.extendedRegexp
grep.threads
grep.fallbackToNoIndex
gpg.program
gpg.format
gpg.<format>.program
gui.commitMsgWidth
gui.diffContext
gui.displayUntracked
gui.encoding
gui.matchTrackingBranch
gui.newBranchTemplate
gui.pruneDuringFetch
gui.trustmtime
gui.spellingDictionary
gui.fastCopyBlame
gui.copyBlameThreshold
gui.blamehistoryctx
guitool.<name>.cmd
guitool.<name>.needsFile
guitool.<name>.noConsole
guitool.<name>.noRescan
guitool.<name>.confirm
guitool.<name>.argPrompt
guitool.<name>.revPrompt
guitool.<name>.revUnmerged
guitool.<name>.title
guitool.<name>.prompt
help.browser
help.format
help.autoCorrect
help.htmlPath
http.proxy
http.proxyAuthMethod
http.emptyAuth
http.delegation
http.extraHeader
http.cookieFile
http.saveCookies
http.version
http.sslVersion
http.sslCipherList
http.sslVerify
http.sslCert
http.sslKey
http.sslCertPasswordProtected
http.sslCAInfo
http.sslCAPath
http.sslBackend
http.schannelCheckRevoke
http.schannelUseSSLCAInfo
http.pinnedpubkey
http.sslTry
http.maxRequests
http.minSessions
http.postBuffer
http.lowSpeedLimit, http.lowSpeedTime
http.noEPSV
http.userAgent
http.followRedirects
http.<url>.*
i18n.commitEncoding
i18n.logOutputEncoding
imap.folder
imap.tunnel
imap.host
imap.user
imap.pass
imap.port
imap.sslverify
imap.preformattedHTML
imap.authMethod
index.recordEndOfIndexEntries
index.recordOffsetTable
index.threads
index.version
init.templateDir
instaweb.browser
instaweb.httpd
instaweb.local
instaweb.modulePath
instaweb.port
interactive.singleKey
interactive.diffFilter
log.abbrevCommit
log.date
log.decorate
log.follow
log.graphColors
log.showRoot
log.showSignature
log.mailmap
mailinfo.scissors
mailmap.file
mailmap.blob
man.viewer
man.<tool>.cmd
man.<tool>.path
merge.conflictStyle
merge.defaultToUpstream
merge.ff
merge.verifySignatures
merge.branchdesc
merge.log
merge.renameLimit
merge.renames
merge.directoryRenames
merge.renormalize
merge.stat
merge.tool
merge.guitool
merge.verbosity
merge.<driver>.name
merge.<driver>.driver
merge.<driver>.recursive
mergetool.<tool>.path
mergetool.<tool>.cmd
mergetool.<tool>.trustExitCode
mergetool.meld.hasOutput
mergetool.keepBackup
mergetool.keepTemporaries
mergetool.writeToTemp
mergetool.prompt
notes.mergeStrategy
notes.<name>.mergeStrategy
notes.displayRef
notes.rewrite.<command>
notes.rewriteMode
notes.rewriteRef
pack.window
pack.depth
pack.windowMemory
pack.compression
pack.island
pack.islandCore
pack.deltaCacheSize
pack.deltaCacheLimit
pack.threads
pack.indexVersion
pack.packSizeLimit
pack.useBitmaps
pack.useSparse
pack.writeBitmaps (deprecated)
pack.writeBitmapHashCache
pager.<cmd>
pretty.<name>
protocol.allow
protocol.<name>.allow
protocol.version
pull.ff
pull.rebase
pull.octopus
pull.twohead
push.default
push.followTags
push.gpgSign
push.pushOption
push.recurseSubmodules
rebase.useBuiltin
rebase.stat
rebase.autoSquash
rebase.autoStash
rebase.missingCommitsCheck
rebase.instructionFormat
rebase.abbreviateCommands
rebase.rescheduleFailedExec
receive.advertiseAtomic
receive.advertisePushOptions
receive.autogc
receive.certNonceSeed
receive.certNonceSlop
receive.fsckObjects
receive.fsck.<msg-id>
receive.fsck.skipList
receive.keepAlive
receive.unpackLimit
receive.maxInputSize
receive.denyDeletes
receive.denyDeleteCurrent
receive.denyCurrentBranch
receive.denyNonFastForwards
receive.hideRefs
receive.updateServerInfo
receive.shallowUpdate
remote.pushDefault
remote.<name>.url
remote.<name>.pushurl
remote.<name>.proxy
remote.<name>.proxyAuthMethod
remote.<name>.fetch
remote.<name>.push
remote.<name>.mirror
remote.<name>.skipDefaultUpdate
remote.<name>.skipFetchAll
remote.<name>.receivepack
remote.<name>.uploadpack
remote.<name>.tagOpt
remote.<name>.vcs
remote.<name>.prune
remote.<name>.pruneTags
remote.<name>.promisor
remote.<name>.partialclonefilter
remotes.<group>
repack.useDeltaBaseOffset
repack.packKeptObjects
repack.useDeltaIslands
repack.writeBitmaps
rerere.autoUpdate
rerere.enabled
reset.quiet
sendemail.identity
sendemail.smtpEncryption
sendemail.smtpssl (deprecated)
sendemail.smtpsslcertpath
sendemail.<identity>.*
sendemail.aliasesFile
sendemail.aliasFileType
sendemail.annotate
sendemail.bcc
sendemail.cc
sendemail.ccCmd
sendemail.chainReplyTo
sendemail.confirm
sendemail.envelopeSender
sendemail.from
sendemail.multiEdit
sendemail.signedoffbycc
sendemail.smtpPass
sendemail.suppresscc
sendemail.suppressFrom
sendemail.to
sendemail.tocmd
sendemail.smtpDomain
sendemail.smtpServer
sendemail.smtpServerPort
sendemail.smtpServerOption
sendemail.smtpUser
sendemail.thread
sendemail.transferEncoding
sendemail.validate
sendemail.xmailer
sendemail.signedoffcc
sendemail.smtpBatchSize
sendemail.smtpReloginDelay
sendpack.sideband
sequence.editor
showBranch.default
splitIndex.maxPercentChange
splitIndex.sharedIndexExpire
ssh.variant
status.relativePaths
status.short
status.branch
status.aheadBehind
status.displayCommentPrefix
status.renameLimit
status.renames
status.showStash
status.showUntrackedFiles
status.submoduleSummary
stash.useBuiltin
stash.showPatch
stash.showStat
submodule.<name>.url
submodule.<name>.update
submodule.<name>.branch
submodule.<name>.fetchRecurseSubmodules
submodule.<name>.ignore
submodule.<name>.active
submodule.active
submodule.recurse
submodule.fetchJobs
submodule.alternateLocation
submodule.alternateErrorStrategy
tag.forceSignAnnotated
tag.sort
tag.gpgSign
tar.umask
trace2.normalTarget
trace2.perfTarget
trace2.eventTarget
trace2.normalBrief
trace2.perfBrief
trace2.eventBrief
trace2.eventNesting
trace2.configParams
trace2.destinationDebug
trace2.maxFiles
transfer.fsckObjects
transfer.hideRefs
transfer.unpackLimit
uploadarchive.allowUnreachable
uploadpack.hideRefs
uploadpack.allowTipSHA1InWant
uploadpack.allowReachableSHA1InWant
uploadpack.allowAnySHA1InWant
uploadpack.keepAlive
uploadpack.packObjectsHook
uploadpack.allowFilter
uploadpack.allowRefInWant
url.<base>.insteadOf
url.<base>.pushInsteadOf
user.name
user.email
author.name
author.email
committer.name
committer.email
user.useConfigOnly
user.signingKey
versionsort.prereleaseSuffix (deprecated)
versionsort.suffix
web.browser
worktree.guessRemote
Gitコマンドの使い方一覧
Git設定
ログ&設定値確認
ステージングエリアの操作
ローカルリポジトリの操作
commitのエイリアスなど
commitの内容をステージングエリアや作業ディレクトリに反映