clone url: git://git.m455.casa/repo2html
documentation/create-a-git-forge-with-repo2html.md
This tutorial teaches you how to use repo2html
in a post-receive
hook to
auto-generate HTML representations of bare Git repositories on a remote web
server after you git push
to them.
A Git forge is a website that provides HTML representations of Git repositories, so visitors don't need to clone repositories to view their contents.
This section uses example.com
as a placeholder value. Ensure you replace
example.com
with your own domain when following the procedures below.
This section assumes the following about your server:
ufw
.nginx
as your web server.git.example.com
.Ensure you're in the repo2html git repository, and follow the steps below:
adduser git
.mkdir /var/www/git && chown git:git /var/www/git
.ufw allow 9418
.su git
.mkdir ~/.ssh && chmod 700 ~/.ssh
.touch ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys
.~/.ssh/authorized_keys
.mkdir ~/projects
.git init --bare my-repository
.After you've set up a git user, follow all procedures that don't require root as the git user.
As root, add the following contents to /etc/nginx/sites-available/git.example.com
:
server {
root /var/www/git;
index index.html;
server_name git.example.com;
}
As root, run ln -s /etc/nginx/sites-available/git.example.com /etc/nginx/sites-enabled/
.
As root, run nginx -t
to test your nginx configuration.
As root, run certbot
, and follow the prompts.
As root, run systemctl restart nginx
.
Ensure you're in the repo2html git repository, and follow the steps below:
make dependencies
.make
.make install
.repo2html
Git repository.mkdir ~/bin
.echo "PATH="~/bin:$PATH" >> ~/.profile
.cp assets/post-receive ~/bin
.chmod u+x ~/bin/post-receive
.ln -sf ~/bin/post-receive ~/projects/my-repository/hooks/post-receive
.cp assets/templates/default.html ~/bin
.assets/post-receive
file, change
path/to/directory/containing/template
to ~/bin
repo2html
Git repository.cp assets/git-daemon.service /etc/systemd/system
.systemctl enable --now git-daemon.service
.This section uses example.com
as a placeholder value. Ensure you replace
example.com
with your own domain when following the procedures below.
On your local machine, follow the steps below:
git init my-repository
.cd my-repository
.echo "hello" > my-file.txt
.git add my-file.txt
.git commit -m "my first commit"
.git remote add origin git@example.com:~/projects/my-repository
.git push
.https://git.example.com/my-repository
in your browser.