Setting Up Your Own Git Server
Setting up your own Git server is very useful. You can set up your own Git server on a VPS, VDS, dedicated server, or even on your local machine. 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 an example called git server. This way, you can set up as many git servers as you want.
mkdir /git/example.git
Then in the terminal /git/example.git Go to the directory and type the following code.
git init --bare
That's all!! We've created our Git server. If you want to clone it, you'll need to write the following code:
git clone username@serveripaddress:/git/example.git
It will ask for your server's password.
If you have a local project on your computer and want to add it to your Git server, type the following code in the terminal in your project directory;
git remote add myserver username@serveripaddress:/git/example.git git push myserver -u master
“myserver” You can give any name you want instead. “origin” is a commonly used name.
When you send your commits via push command, your server will ask for the user password.
If you want your server to receive your commits and create your project in another directory when you send them, /git/example.git/hooks under the directory 777 with permission “post-recived” You should create a file named. Why do we want something like this? In your project, gulp Let's say you have commands that perform compilation operations like this. After you submit your components, you might want your gulp processes to run automatically and your project is ready. You could even have the development and production branches run automatically in separate folders.
post-received Edit the file as follows.
#!/bin/bash GIT_WORK_TREE=/home/project-directory/ git checkout -f master
You can adjust the directory location as you wish.
If you are using a program like Composer or Bower, you can make it work as follows.
#!/bin/bash GIT_WORK_TREE=/home/project-directory/ git checkout -f master cd /home/project-directory/ php composer.phar update cd /home/project-directory/ bower install