Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

run bash script after git clone

Tags:

git

git-clone

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?

like image 880
Andre Baumeier Avatar asked Aug 12 '13 13:08

Andre Baumeier


1 Answers

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 &&.

like image 190
Ruslan Osipov Avatar answered Oct 09 '22 18:10

Ruslan Osipov