<commit_before>#+TITLE: Useful GIT configuration options

* Global Ignores

Tired of setting up editor swap files or Mac DSStore files in all of
your git projects.
The solution is to create a global gitignore that operates across all
of your projects in addition to each projects custom .gitignore

Convention is for your global gitignore file to be in
~$HOME/.gitignore_global~.

#+BEGIN_SRC shell
git config --global core.excludesfile ~/.gitignore_global
#+END_SRC

* Creating global hooks

By default the hooks directory is $GIT_DIR/hooks, but that can be
changed via the core.hooksPath configuration variable.

#+BEGIN_SRC shell
git config --global core.hooksPath </path/to/my/centralized/hooks>
#+END_SRC

Then override it in specific repos where required with the following
command.

#+BEGIN_SRC shell
git config core.hooksPath </path/to/my/overridden/hooks>
#+END_SRC

A good choice for and overridden path would be the default when a
global path is not set which is ~$GIT_Dir/hooks~ ie the hooks directory
in the projects .git directory.

This repo has a hooks directory with the purpose being you can set
your core.HooksPath to point to it and gain the benefits of checking
for things such as innapropriate whitespace on precommit globally for
all projects.<commit_msg>Add instructions for commiting with errant whitespace.<commit_after>#+TITLE: Useful GIT configuration options

* Global Ignores

Tired of setting up editor swap files or Mac DSStore files in all of
your git projects.
The solution is to create a global gitignore that operates across all
of your projects in addition to each projects custom .gitignore

Convention is for your global gitignore file to be in
~$HOME/.gitignore_global~.

#+BEGIN_SRC shell
git config --global core.excludesfile ~/.gitignore_global
#+END_SRC

* Creating global hooks

By default the hooks directory is $GIT_DIR/hooks, but that can be
changed via the core.hooksPath configuration variable.

#+BEGIN_SRC shell
git config --global core.hooksPath </path/to/my/centralized/hooks>
#+END_SRC

Then override it in specific repos where required with the following
command.

#+BEGIN_SRC shell
git config core.hooksPath </path/to/my/overridden/hooks>
#+END_SRC

A good choice for and overridden path would be the default when a
global path is not set which is ~$GIT_Dir/hooks~ ie the hooks directory
in the projects .git directory.

This repo has a hooks directory with the purpose being you can set
your core.HooksPath to point to it and gain the benefits of checking
for things such as innapropriate whitespace on precommit globally for
all projects.

** Committing a file that fails hook validation

Sometime you have a file that may have errant whitespace, but you do
not have control over its format (eg. structure.sql file in a rails
project).

You may need to commit it as is and override the hook checks.

#+BEGIN_SRC ruby
git commit --no-verify

# or use the shorter -n switch

git commit -n
#+END_SRC

Magit also allows for this option to be added ~c -n c~.
{'fraction_non_alphanumeric': 0.05179282868525897, 'fraction_numerical': 0.0, 'mean_word_length': 4.48816029143898, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4842431', 'n_tokens_mistral': 855, 'n_tokens_neox': 840, 'n_words': 436}