Skip to content

Latest commit

 

History

History
171 lines (131 loc) · 7.32 KB

git-configuration.md

File metadata and controls

171 lines (131 loc) · 7.32 KB

Git configuration reference

The default Git configuration senv installs, option by option, and the gcu command that completes it per repository.

Because a senv session defines its own HOME, Git resolves ~/.gitconfig to %HOME%\.gitconfig inside the session, and to your Windows profile outside of it. The senv Git configuration therefore only applies inside senv sessions.

Three pieces are installed by setup.bat and the gits install hook:

File Source Role
%HOME%\.gitconfig .gitconfig template at the senv root main configuration, all options below
%HOME%\.config\git\config .config.git.config sets core.autocrlf=false at the lowest level
%HOME%\bin\gcu.bat generated by installs\gits.post.bat per-repository identity command

gcu: set your identity in one repository

cd /d %PROG%\git\myrepo
gcu

gcu.bat contains exactly two commands, built from the FULLNAME and USERMAIL registered in %HOME%\bin\senv.local.pre.bat:

git config user.name "Full Name"
git config user.email "user@example.corp"

Run it once inside each freshly cloned repository. Until then, commits are refused: that is the point of user.useConfigOnly, below. The reasoning behind this deliberate friction is in one identity per repository.

gcua: apply the identity to a whole folder of repositories

gcua [folder] [hosts-list|-] [--force] [--dry-run]

gcua walks every first-level git repository under folder (default: %PROG%\git, the cdg clone home) and runs the same two git config commands as gcu in each, under three guards:

  • a repository that already has a local user.email is not touched (--force overrides),
  • when a hosts list is active, a repository is stamped only if every URL of every remote matches one of the listed services; one remote on an unlisted service (for example github.com) and the repository is skipped,
  • with a hosts list active, a repository without any remote is skipped too: it cannot be classified.

The hosts list is the team opt-in, one pattern per line (# comments):

# custom\senv.custom.<profile>.gcua.list
git.example.corp
gitlab.internal.example

Two files can carry the list, in the custom repository:

  • custom\senv.custom.all_teams.gcua.list: the default, shared by every profile,
  • custom\senv.custom.<profile>.gcua.list: per-profile; when present it has priority over the all-teams list for that profile.

Resolution order: explicit second argument; - to disable the filter and stamp everything (skip-if-set still applies); the per-profile list of the active profile; the all-teams list. With no list at all and no explicit -, gcua does nothing.

Every decision is reported per repository, with the batcolors levels:

TASK=>: [gcua.bat] Must apply git identity 'Full Name' / 'user@example.corp' under 'C:\Users\me\git'
OK    : [gcua.bat] [set] 'C:\...\corp1': 'Full Name' / 'user@example.corp'
INFO  : [gcua.bat] [already] 'C:\...\perso': 'perso@example.com' kept
WARN  : [gcua.bat] [skip] 'C:\...\mixed': remote outside the listed services
OK    : [gcua.bat] git identity applied under 'C:\Users\me\git': 1 set, 1 already set, 1 external, 0 without remote

Testing it on your own folder: --dry-run prints the same report, would set instead of set, and writes nothing:

gcua C:\Users\me\git myhosts.list --dry-run
gcua C:\Users\me\git - --dry-run

The first form previews with a hosts list of your choice, the second with no filter at all. Outside a senv session, gcua still works standalone: run it as %PRGS%\senv\bin\gcua.bat, with git on the PATH; the identity is read from %HOME%\bin\senv.local.pre.bat (or the default %USERPROFILE%\home_senv), or from FULLNAME / USERMAIL set by hand before the call.

Setup integration: at the end of every setup.bat / s run (so also up, upg, upa), setup calls gcua automatically when a list applies to the active profile: its own senv.custom.<profile>.gcua.list, or the shared senv.custom.all_teams.gcua.list. Both travel from custom\ to %HOME%\bin at setup time. With neither file, there is no automatic stamping.

[user]

Option Value Effect
useConfigOnly true Git never guesses an identity (from the OS user or hostname) and never uses a global fallback for commits: git commit fails with "no email was given" until user.name and user.email are set in the repository itself, one gcu away.

[alias]

Alias Effect
st git status
br git branch
lg, lg2 compact colored graph log (hash, date, relative age, refs, subject, author)
lmsg log without patches: hash, short date, subject and body

[core]

Option Value Effect
autocrlf false no end-of-line conversion: files keep the endings recorded in the repository (batch files must stay CRLF, and .gitattributes rules the exceptions)
safecrlf false no warning or refusal on mixed endings, consistent with autocrlf=false
commitGraph true read the commit-graph file for faster git log/git branch operations
fscache true cache file-system metadata in memory: much faster git status on Windows
filemode, symlinks, ignorecase, ... Windows defaults standard repository flags carried by the template so every clone behaves the same on Windows

[rebase], [pull], [push]

Option Value Effect
rebase.autostash true a rebase stashes local changes first and restores them after
pull.rebase true git pull rebases instead of creating merge commits
push.default upstream git push targets the configured upstream branch only

[protocol], [gc], [init], [rerere], [http]

Option Value Effect
protocol.version 2 faster fetch negotiation
gc.writeCommitGraph true maintenance keeps the commit-graph up to date
init.defaultBranch main new repositories start on main
rerere.enabled true record and replay conflict resolutions across rebases and merges
http.sslBackend schannel use the Windows TLS stack and its certificate store, instead of a bundled OpenSSL

[credential]

Option Value Effect
credential.helper manager-core Git Credential Manager stores and serves HTTPS credentials
credential.helperselector.selected manager-core pre-selects that helper, no popup on first use

The gits install hook re-applies the baseline options (core.fscache, rerere.enabled, http.sslBackend) with git config --global on every install or update, so existing HOMEs converge without waiting for a fresh .gitconfig.

Corporate additions (CA bundle, per-host settings, a proxy credential provider, an alternative helper for older Git versions) come from the private custom\gits.post.bat hook, not from this template.

Related: environment variables, doskey aliases, public engine, private data.