Skip to content

Git

Save credentials to cache

Terminal window
git config --global credential.helper cache
git config --global --list
# To remove
git config --global --unset credential.helper
Terminal window
# list stashed older then 2 months
git stash list --before="2 month ago" --date=relative
STASHES_FOR_CLEANUP=$(git stash list --before="2 month ago" | sort -r)

Configure pager

Terminal window
# List all configs
gh config list
# Set pager to cat
gh config set pager cat
# Include work conf (only if file exists)
[include]
path = ~/dotfiles/work/work.gitconfig
# Based on folder
[includeIf "gitdir:~/work/**"]
path = ~/dotfiles/work/work.gitconfig
# Based on remote
[includeIf "hasconfig:remote.*.url:git@github.com:orgname/**"]
path = ~/dotfiles/work/work.gitconfig

Windows uses Credential Manager to store git credentials (Control Panel \ Credential Manager).

Check with git config --list to see if credential.helper=manager.

Using option format:<format-string> with %G? format-string show signature status for commits:

  • G for a good (valid) signature
  • B for a bad signature
  • U for a good signature with unknown validity
  • X for a good signature that has expired
  • Y for a good signature made by an expired key
  • R for a good signature made by a revoked key
  • E if the signature cannot be checked (e.g. missing key) and “N” for no signature

e.g. with prettylog = log --graph --pretty=format:'%C(red)%h%C(reset) -%C(yellow)%d%C(reset) %s %C(green)(%cr) %C(bold blue)<%an %G?>%C(reset)' --abbrev-commit --date=relative will result something like:

Terminal window
* 6d4c2db - some commit message (5 weeks ago) <Petteri Vaarala G>