config

installation

[!NOTE|label:references:]

  • ubuntu

from source

[!NOTE|label:references:]

location

[!NOTE|label:locations]

SCOPE
WINDOWS
UNIX-LIKE

system

<GIT_DIR>\etc\gitconfig

<GIT_DIR>/etc/gitconfig

system example

%LOCALAPPDATA%\Programs\Git\etc\gitconfig

/usr/local/etc/gitconfig

global

%USERPROFILE%\.gitconfig

$HOME/.gitconfig

local

<git-repo>\.git\config

<git-repo>/.git/config

portable

%PROGRAMDATA%\Git\config

-

get locations

  • windows

  • osx

  • edit config file

list

  • list all with scope

  • list origin

  • list single scope only

    • list local only

    • list global

    • list system

get from all configure

colors

[!NOTE|label:references:]

gitconfig

help

credential

[!NOTE]

TOKEN TYPE

GIT OPERATIONS (clone/push)

GIT LFS UPLOAD/DOWNLOAD

GITHUB ACTIONS (WORKFLOW)

semantic-release

GITHUB API (REST/GRAPHQL)

PRIVATE SUBMODULES

GITHUB CLI (GH)

NOTES

Fine-grained PAT

βœ“

βœ— Fails (LFS lock verification denied)

βœ“

βœ“

βœ“

βœ—

⚠️ Partially supported

Secure and scoped, but limited in CLI/automation contexts like Git LFS

Classic PAT

βœ“

βœ“

βœ“

βœ“

βœ“

βœ“

βœ“

Recommended for CLI tools, LFS, CI/CD, automation, and broad API access

using specific PAT

  • include.path

  • GIT_CREDENTIAL_HELPER

  • GIT_ASKPASS and core.askPass

.git-credentials file keeping revert back

[!TIP|label:reason:]

  • in macOS, the osxkeychain helper is used by default, which stores credentials in the macOS Keychain. even if the .git-credentials file is manual updated, the osxkeychain helper will overwrite it with the credentials stored in the Keychain.

  • solutions:

  • completely disable the osxkeychain helper in global config

  • update the password in keychain

git lfs

[!NOTE|label:references:]

  • git-lfs not support Fine-grained Token (FGPAT) credential, reason:

  • git lfs is NOT push into the git repo, but push the LFS objects to the sepcific endpoint:

  • the git-lfs will try to execute:

    • /locks/verify : require write access

    • /info/lfs/objects/batch (deploy LFS object) : require read/write access

    • have to use the token in Authorization: Basic header

  • but the Fine-grained Token (FGPAT) only support git push and git pull operations, not support the private API:

    • /info/lfs/objects/batch

    • /locks/verify

  • why Classic Token (PAT) works, since it will not restrict the access to endpoint:

  • repo scope: read/write access to code

  • write:packages scope: write access to packages

  • read:packages scope: read access to packages

  • references:

tips

environment failed to $ ssh -vT git@github.com -p 22

  1. using https instead of ssh first

  2. setup credential

  3. create the credential file

    • to read the credentials file

with GIT_USERNAME and GIT_ASKPASS

[!NOTE|label:references:]

[!TIP]

  • the git-lfs NOT support core.askPass. it use credential.helper only

http.cookiefile

[!NOTE|label:references:]

[!TIP|label:check expiration]

FIELD #
VALUE (EXAMPLE)
PURPOSE

1

.googlesource.com

Domain: target domain the cookie applies to (including subdomains)

2

TRUE

Include Subdomains: if TRUE, the cookie is sent to subdomains

3

/

Path: url path prefix the cookie is valid for

4

TRUE

Secure Only: if TRUE, cookie is only sent over HTTPS

5

2147483647

Expiration (Unix time): when the cookie expires (here: 2038-01-19)

6

o

Cookie Name: gerrit expects the cookie to be named o

7

git-account.gmail.com=...

Cookie Value: key-value pair used for authentication (username=token)

cookie value explaination

COMPONENT
EXAMPLE
DESCRIPTION

Username / Identifier

git-account.gmail.com

identity used by Gerrit

Authentication Token

1//0ABC...XYZ

oAuth-style or Gerrit token

Separator

=

separates identity from token

generate cookies

[!TIP|label:references:]

verify

[!NOTE|label:googlesource repos]

commit.template

  • usage

default configuration

  • core.editor

    • use vim ( the ubiqutos text editor ) as Git's default editor

    core.editor
  • init.defaultBranch

    • override the default branch name for new repositories

    core.editor
  • core.autocrlf

    [!TIP|label:see also:]

    • checkout windows-style, commit unix-style line endings

    • checkout as-is, commit unix-style line endings

    • checkout as-is, commit as-is

    core.editor
  • pull.rebase

    core.editor
  • core.fscache & core.symlinks

    • enable file system caching

    • enable symbolic links

    core.editor
  • core.fsmonitor

    • enable experimental built-in file system monitor

    core.editor

__git_ps1

[!NOTE|label:localtion]

  • osx: $(brew --prefix git)/etc/bash_completion.d/git-prompt.sh

add to bash_completion.d

tig

[!NOTE|label:references:]

  • result

troubleshooting

[!TIP]

ld: archive member '/' not a mach-o file

[!NOTE]

  • xCode

Last updated

Was this helpful?