Skip to content

Commit

Permalink
git: restructure config and relative include file path
Browse files Browse the repository at this point in the history
  • Loading branch information
practicalli-johnny committed Dec 28, 2023
1 parent 797560a commit 5b09739
Show file tree
Hide file tree
Showing 13 changed files with 377 additions and 116 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [Unreleased]

### Added
- git: ssh key signing

### Changed
- git: restructure multiple configs, using relative include file paths


## 2023-09-28
### Added
Expand Down
7 changes: 7 additions & 0 deletions git/commit-message-company
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
LINEARCODE Summary

# Elaboration

# Issue Status:
# Resolve: #
# Related: #
7 changes: 7 additions & 0 deletions git/commit-message-practicalli
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
topic: summary

# Elaboration

# Issue Status:
# Resolve: #
# Related: #
6 changes: 0 additions & 6 deletions git/commit-message-template

This file was deleted.

65 changes: 32 additions & 33 deletions git/config
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,30 @@
##
## Adjust paths if not saved in `~/.config/git/`

## ------ Identity ------ ##
## --- Conditional Configuration
# Uses relative file path to this configuration file

# Default identity configuration
# Default personal identity configuration
[include]
path = ~/.config/git/identity-practicalli
path = config-johnny

# Over-ride identify for specific directories
[includeIf "gitdir:~/projects/company-name"]
path = ~/.config/git/identity-company-name
# Practicalli community work
[includeIf "gitdir:~/projects/practicalli/"]
path = config-practicalli

# Commercial work
[includeIf "gitdir:~/commercial-projects/company/"]
path = config-company

## ------ Git Behaviour ------ ##

## -- Common Git Behaviour

[init]
# scripts and hooks to add when creating a new local Git repository
# templateDir = ~/.config/git/repo-template/

# default branch name when creating a new local repository
defaultBranch = main

[core]
# Set which editor to use for editing commit messages (when not included with -m)
Expand All @@ -22,51 +34,34 @@
editor = astronvim

# file and directory patterns to ignore across all projects
excludesfile = ~/.config/git/ignore
# excludesfile = ~/.config/git/ignore

# Tool to page through long output (e.g. git log). `less` is default
# pager = less

# Ensure Linux & MacOSX line endings in checked out text files
autocrlf = input

[commit]
# Default commit message - useful if team has a commit message policy
template = ~/.config/git/commit-message-template

[fetch]
# Remove deleted remote branches from local repository
prune = true

[difftool "meld"]
cmd = meld \"$LOCAL\" \"$REMOTE\"
path =

[init]
# scripts and hooks to add when creating a new local Git repository
# templateDir = ~/.config/git/repo-template/
[log]
abbrevCommit = true

# default branch name when creating a new local repository
defaultBranch = main
[push]
# Set local brach to track new remote branch automatically, Git 2.37.0 onward
autoSetupRemote = true

[mergetool "meld"]
cmd = meld \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
trustExitCode = true
[diff]
tool = nvimdiff

[merge]
# Include common parent when merge conflicts arise
conflictstyle = diff3

[log]
abbrevCommit = true

[push]
# Set local brach to track new remote branch automatically
# Requires Git 2.37.0
autoSetupRemote = true


## ------ Git commands ------ ##
## --- Git commands

# command line shot cuts
[alias]
Expand All @@ -93,7 +88,11 @@
# Set timeout (in 0.1 second steps) before git automatically changes the command
# autocorrect = 50


## -- Git CLI

[credential "https://github.com"]
helper = !/usr/bin/gh auth git-credential
[credential "https://gist.github.com"]
helper = !/usr/bin/gh auth git-credential

72 changes: 72 additions & 0 deletions git/config-company-linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
## ------ Identity ------ ##
# Add details for specific company identity
# Assumes use of Linux for ~ expansion

# Add identity to all commits
[user]
name = Johnny Stevenson

# Add company email address to GitHub account
# and use when creating SSH key
email = "johnny@company-name.com"

# SSH Key signing with allowed SSH key signatures
signingkey = ~/.ssh/id-company.pub

## Identity for using GitHub API
[github]
user = practicalli-johnny

## ------ Git Behaviour ------ ##

[init]
# scripts and hooks to add when creating a new local Git repository
# templateDir = ~/.config/git/repo-template/

# default branch name when creating a new local repository
defaultBranch = main

[core]
# Set which editor to use for editing commit messages (when not included with -m)
# VISUAL or EDITOR environment variables also set the choice of editor
# vi used if not set. Typical examples are nvim or emacsclient
editor = astronvim

# file and directory patterns to ignore across all projects
excludesfile = ~/.config/git/ignore-company

# Tool to page through long output (e.g. git log). `less` is default
# pager = less

# Ensure Linux & MacOSX line endings in checked out text files
autocrlf = input

[commit]
# Default commit message - useful if team has a commit message policy
template = ~/.config/git/commit-message-company
# Automatically sign every commit
gpgsign = true

[tag]
# Automatically sign every tag
gpgsign = true

[fetch]
# Remove deleted remote branches from local repository
prune = true

## ------ Security ------ ##

# Use SSH key passphrase stored in MacOSX Keychain with ssh-add command
# ssh-add --apple-use-keychain $HOME/.ssh/id_ed25519
# [credential]
# helper = osxkeychain

# Use SSH key to sign commits and tags
[gpg]
format = ssh

# Self-define SSH keys that should be considered authentic locally
[gpg "ssh"]
allowedSignersFile = ~/.config/git/allowed-signatures-company

95 changes: 95 additions & 0 deletions git/config-company-macosx
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Company specific Git configuration
#
# Assumes use of MacOSX and ~ expansion not working for paths
# Replace /Users/practicalli/ path with your own $HOME location

## -- Identity
# Add identity to all commits
[user]
name = Johnny Stevenson

# Add company email address to GitHub account
# and use when creating SSH key
email = "johnny@company-name.com"

# SSH Key signing with allowed SSH key signatures
signingkey = /Users/practicalli/.ssh/id-company.pub

## Identity for using GitHub API
[github]
user = practicalli-johnny

## -- Git Behaviour

[init]
# scripts and hooks to add when creating a new local Git repository
# templateDir = ~/.config/git/repo-template/

# default branch name when creating a new local repository
defaultBranch = main

[core]
# Set which editor to use for editing commit messages (when not included with -m)
# VISUAL or EDITOR environment variables also set the choice of editor
# vi used if not set. Typical examples are nvim or emacsclient
editor = astronvim

# file and directory patterns to ignore across all projects
excludesfile = /Users/practicalli/.config/git/ignore-company

# Tool to page through long output (e.g. git log). `less` is default
# pager = less

# Ensure Linux & MacOSX line endings in checked out text files
autocrlf = input

[commit]
# Default commit message - useful if team has a commit message policy
template = /Users/practicalli/.config/git/commit-message-company
# Automatically sign every commit
gpgsign = true

[tag]
# Automatically sign every tag
gpgsign = true

[fetch]
# Remove deleted remote branches from local repository
prune = true

## -- Security

# Use SSH key passphrase stored in MacOSX Keychain with ssh-add command
# ssh-add --apple-use-keychain $HOME/.ssh/id_ed25519
[credential]
helper = osxkeychain

# Use SSH key to sign commits and tags
[gpg]
format = ssh

# Self-define SSH keys that should be considered authentic locally
[gpg "ssh"]
allowedSignersFile = /Users/practicalli/.config/git/allowed-signatures-company


## -- Diff & Merge

# TODO: test configuration for p4merg tool on MacOSX

# [diff]
# tool = p4merge

# [difftool "p4merge"]
# cmd = "p4merge $LOCAL $REMOTE"

# [merge]
# tool = p4merge

# [mergetool "p4merge"]
# cmd = "p4merge $BASE $LOCAl $REMOTE $MERGED"
# trustExitCode = true
# keepTemporaries = false
# keepBackup = false
# prompt = false

19 changes: 19 additions & 0 deletions git/config-johnny
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## -- Identity

# Add identity to all commits
[user]
name = Johnny Practicalli

# Use GitHub no-reply email address to keep real address private
email = "******+practicalli-john@users.noreply.github.com"

## Identity for using GitHub API
[github]
user = practicalli-johnny


## -- Git Behaviour

[commit]
# Default commit message - useful if team has a commit message policy
template = ~/.config/git/commit-message-practicalli
Loading

0 comments on commit 5b09739

Please sign in to comment.