Go to Linux Server Server Setup
Setting up a Git server is quite useful and convenient. You can set up a private Git server on your VPS, VPS, or dedicated servers. I'm assuming you've installed Git on your Linux server.
First, we need to create a git directory under the root directory. In the code below, I'll create a git server named example. This means you can set up as many git servers as you want.
mkdir /git/example.git
Then, we go to the /git/example.git directory in the terminal and write the following code.
git init --bare
That's it. We've created our Git server. If you want to clone it, you'll need to write the following code.
git clone username@vpsipaddress:/git/example.git
If you have a local project on your computer and want to include it in your git server, go to your project directory in the terminal and type the following code.
git remote add anyname username@vpsipaddress:/git/example.git git push anyname -u master
When sending your commits and files with the push command, your server will ask for your user password.
If you want your Git server to receive commits and files when you send them to it and create them in another directory, you should create a file named post-receive with permissions of 777 under the /git/example.git/hooks directory. What does this do? Imagine publishing your project from your server. After developing the project on your computer, simply push the changes to your Git server, and your published project will automatically receive the changes.
Then edit the contents of this file as follows. You can adjust the directory location as desired.
#!/bin/bash GIT_WORK_TREE=/home/ornekproject/ git checkout -f master
If you are using things like composer or bower, you can make them work by editing them as follows.
#!/bin/bash GIT_WORK_TREE=/home/ornekproje/ git checkout -f master cd /home/ornekproje/ php composer.phar update cd /home/ornekproje/ bower install