Client Git Repositories

Certain hosting providers have the luxury of using git as a version control system. By connecting to your server via SSH, anyone with access can manage a version-controlled directory using their favorite git client. In this article, we'll go over a brief tutorial on how to set up a bare git repository on a Linux server.

photo-1558494949-ef010cbdcc31

To start, tunnel into your server with SSH. Then, create a bare git repository using the code below. Be sure to replace %reponame% with your desired repository name.

mkdir %reponame%.git && cd %reponame%.git
git --bare init
vi

Once you're in the vi editor, press the [i] key to insert the following code into a new file. Again, make sure to replace %path/to/working/theme/or/plugin% with the path to your desired working directory.

#!/bin/sh
GIT_WORK_TREE=~/%path/to/working/theme/or/plugin% git checkout -f

Next, hit the [esc] key to end editing of the file. Type :w post-receive to save the file, and then press :q to quit the vi editor.

Finally, insert the following code into the terminal window, making sure to replace %path/to/working/theme/or/plugin% with the path to your desired working directory.

chmod +x post-receive
mkdir ~/%path/to/working/theme/or/plugin%

And there you have it! You've successfully set up a bare git repository on your Linux server. Now, you can take advantage of git's powerful version control capabilities to manage your files and projects more efficiently.