Git Cheat Sheet

GitHub Linguist Overrides

Use gitattributes to modify how GitHub detects file types. See Overrides.

Multiple Git Identities

Git config includes.

Repos organized by the identity:

~/src
|-- work
    |-- work-repo-1
    |-- work-repo-2
|-- other
    |-- other-repo-1
    |-- other-repo-2

.gitconfig:

[user]
  name = Bruce Wayne
  email = bruce@wayneenterprises.com
[includeIf "gitdir:~/src/other"]
  path = .gitconfig-other

.gitconfig-other:

[user]
  name = Batman
  email = darkknight@justice.league

Check the effective configuration:

git config --list --show-origin --show-scope

Shallow And Partial Clones

Useful only with large monorepos, don't use with normal smallish repos. See e.g. Get up to speed with partial clone and shallow clone.

Shallow clones are good for single builds:

git clone --depth=1 --single-branch --branch=<BRANCH> <REPOSITORY_URL>

Partial (blobless) fetches some blobs later on-demand:

git clone --filter=blob:none <REPOSITORY_URL>

Page Metadata

Source: git.md Created: 2023-10-18T15:48:10+03:00 Changed: 2024-03-05T13:36:02+02:00