Git

Git Hooks

Git Hooks

Git hooks are scripts that Git automatically executes before or after specific events, such as committing changes or pushing to a repository. They allow you to customize and automate tasks related to these events, such as enforcing code style rules, running tests, or sending notifications. Hooks are useful for maintaining code quality and ensuring consistent workflows across a team. They can be set up in the .git/hooks directory of your repository and include both client-side and server-side hooks.

Git: Add Date to Git Commit

Git: Add Date to Git Commit

To add a date to a git commit message from the command line:

git commit -m "blog update on `date +'%Y-%m-%d'`"

will result in

* e81bc5d - (25 minutes ago) blog update on 2023-04-20 - Mark S

Git: Pretty Git Graphs

Git: Pretty Git Graphs

In order to view git history from the command line:

git log

However if you want to view the history in a cleaner format I recommend a custom git log.

Add the following to .gitconfig (typically at ~.gitconfig)

[alias]
    lg = lg1
    lg1 = lg1-specific --all
    lg2 = lg2-specific --all

    lg1-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)'
    lg2-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(auto)%d%C(reset)%n''          %C(white)%s%C(reset) %C(dim white)- %an%C(reset)'

Now from the command line run: