Git configurations

Verbose Git

Add lines below to your ~/.bashrc or whatever you prefer:

export GIT_TRACE=1
export GIT_CURL_VERBOSE=1
export GIT_SSH_COMMAND="ssh -vvv"

Automatic version tagging

Due to instant shipping of our main branch codes on production, it is essential to publish a version number with the code. In this case, we are writing version to a .txt file which is readable by the code as required. This code is based on a stackoverflow.com answer.

#!/bin/bash  
  
ver_file=version.txt  
> $ver_file  
date +"%Y-%m-%d %T %:z" >> $ver_file  
echo -n "Parent: " >> $ver_file  
git rev-parse HEAD >> $ver_file  
git add $ver_file  
echo "Date-time and parent commit added to '$ver_file'"  
exit 0

This code must placed in ~/.git-templates/hooks/pre-commit with execute permission. Please not that you can permit a file to execute with chmod a+x ~/.git-templates/hooks/pre-commit command Linux. Then git must be configured to refer to the templates directory git config --global init.templatedir '~/.git-templates'. This will not work without re-initialization of the repository: git init.