Git tip: use symlink for multiple repository clones

Here is a simple tip to help consolidate some of your Git repository clones on your servers.

Anytime you have to clone the same repository on the same server (for different apps/folders), it requires you to pull changes in each folder (every time a change is pushed).

A better way is to create a single folder on your server, and anywhere you need to access that cloned repository, just create a symlink (dynamic folder link) to the main folder. This way you only have to pull once, and every spot instantly gets the changes.

Creating a symlink is simple using the command line. Let’s say you name your cloned repository “cloned” and your app directory is called “global.” First navigate to the appropriate directory, then issue:

ln -s /path/to/cloned/directory global

A new folder called “global” will appear, but instead of holding files itself, it just links to the source directory. Your web application won’t know the difference.