9

I want to run a simple bash script after a git clone was made, that checks the url of the repository origin and applies specific git-author settings.

this configuration shall be done on the local environment (not in the repository).

is there a configuration setting that I can apply to call a bash script after a git clone has completed?

Andre Baumeier
  • 211
  • 2
  • 6

1 Answers1

8

Let us say the bash script you intend to run is in a file by the name shellscript.sh and it is on your path:

You can add the following bash function to your ~/.bashrc.

git() { 
   if [[ $1 == "clone" ]]; then 
      command git "$@" && shellscript.sh; 
   else 
      command git "$@"; 
   fi; 
}

Note: You can add any command after &&.

Litmus
  • 10,558
  • 6
  • 29
  • 44
Ruslan Osipov
  • 5,655
  • 4
  • 29
  • 44