Time comes when big boys wants to build their own private repos to commit or deploy. Well my time has come.

Install git and add user, email and favorite editor

# pkg install git
# git config --global user.name "user"
# git config --global user.email "email"
# git config --global core.editor "ee"
# git config --list

Add to rc.conf

git_daemon_enable="YES"
git_daemon_directory="/dir/to/git/repos"

Start daemon

service git_daemon start

Install cgi handler

# pkg install fcgiwrap

Add to rc.conf


fcgiwrap_enable="YES"
fcgiwrap_user="www"
fcgiwrap_socker_owner="www"
fcgiwrap_socket_group="www"
fcgiwrap_git_user="www"

Add new nginx configuration

server {
	listen 80;
	server_name domain;
	return 301 https://$server_name$request_uri;
}

server {
	listen 443;
	server_name domain;

	root /home/path-to-root;
		
    	ssl on;
    	ssl_certificate /usr/local/etc/letsencrypt/live/domain/fullchain.pem;
    	ssl_certificate_key /usr/local/etc/letsencrypt/live/domain/privkey.pem;
    	ssl_session_cache shared:SSL:10m;

	auth_basic "Unauthorized";
	auth_basic_user_file /home/user/git/.passwords;

	location /gitweb.cgi {
        	fastcgi_pass    unix:/var/run/fcgiwrap/fcgiwrap.sock;
        	fastcgi_param 	REMOTE_USER $remote_user;
        	fastcgi_param	  SCRIPT_NAME gitweb.cgi;
		fastcgi_param   SCRIPT_FILENAME /home/path-to-root/gitweb.cgi;
        	fastcgi_param   DOCUMENT_ROOT /home/path-to-root;
		fastcgi_param	  GITWEB_CONFIG /usr/local/etc/git/gitweb.conf;
		include         fastcgi_params;
	}

    	location / {
		root            /home/path-to-root;
        	index           gitweb.cgi;
        	autoindex       off;
    	}
}

open /usr/local/etc/git/gitweb.conf and add path to root directory of git repos

our $projectroot="/home/user/git";

And now it’s time to create a new repo

cd /home/user/git
mkdir project-name.git
cd project-name.git
git --bare init

Now you will be able to commit changes on this project. Enjoy.