This is a little memo about uploading local repository codes to remote git server.
First of all you will need to install git on both local PC and remote nginx server. Here will just assume you already have git installed and have local repository with source code already working on.
Now let’s initialize the remote repository.
1 2 3 |
cd /opt/git git init --bare test.git chmod -R 777 test.git |
Have basic authentication user and password.
1 2 |
cd /somedirectory sudo htpasswd -c .test test |
Since will be working with Nginx for web server, will need to install fcgiwrap to work the git Simple HTTP. Here will assume fcgiwrap is already installed. Inside the Nginx will create virtual host.
1 |
vi /etc/nginx/sites-available/git-test.test.com |
And now inside the config file…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
server { listen 80; server_name git-test.test.com; root /opt/git; access_log /var/log/nginx/git_access.log; error_log /var/log/nginx/git_error.log; location ~ /git(/.*) { auth_basic "Restricted"; auth_basic_user_file /etc/htpasswd/.test; fastcgi_pass unix:/var/run/fcgiwrap.socket; fastcgi_param DOCUMENT_ROOT /usr/lib/get-core; fastcgi_param GIT_HTTP_EXPORT_ALL ""; fastcgi_param GIT_PROJECT_ROOT /opt/git; fastcgi_param PATH_INFO $1; fastcgi_param REMOTE_USER $remote_user; fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend; include /etc/nginx/fastcgi_params; } } |
Please memo about the order of settings written inside “location” or good possibility the setup will not work. If the setup is not working check the error log. Now make the sim link and restart the nginx service. At this point make sure fcgiwrap is running on service.
1 2 |
ln -s /etc/nginx/sites-available/git-test.test.com /etc/nginx/sites-enabled/git-test.test.com sudo service nginx restart |
Go to your local PC repository and enter below command.
1 |
git remote add origin http://git-test.test.com/git/test.git |
Enter user and password and you should be all set.