diff options
Diffstat (limited to 'public/archive/linux/Git_Server/index.html')
| -rw-r--r-- | public/archive/linux/Git_Server/index.html | 167 |
1 files changed, 167 insertions, 0 deletions
diff --git a/public/archive/linux/Git_Server/index.html b/public/archive/linux/Git_Server/index.html new file mode 100644 index 0000000..4fe1d07 --- /dev/null +++ b/public/archive/linux/Git_Server/index.html @@ -0,0 +1,167 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <link rel="stylesheet" href="/assets/css/main.css"> + <title>How to start your own epic Git server!</title> + </head> + <body> + <header> + <nav class="site-nav"> + <div class="nav-container"> + <div class="nav-left"> + <a href="/" class="site-title">Shipwreckt</a> + </div> + <ul class="nav-right"> + <li><a href="/">Home</a></li> + <li><a href="/archive/">Archive</a></li> + <li><a href="/links/">Links</a></li> + <li><a href="/contact/">Contact</a></li> + </ul> + </div> + </nav> + <h1>How to start your own epic Git server!</h1> + <p class="post-date">February 23, 2025</p> + </header> + <article> + <div class="post-content"> + <hr> + <p>Quick guide on how to set up a git server with stagic html website.</p> +<hr> +<h2>What you will need 📋</h2> +<ul> +<li>A computer with Linux 🐧🖥️</li> +<li>A VPS with Linux instaled 🐧🗄️</li> +<li>Some terminal knowlage 🧠</li> +<li>Ideally have a domain name</li> +</ul> +<hr> +<h3>1) Install Git</h3> +<blockquote> +<p># sudo apt install git</p> +</blockquote> +<hr> +<h3>2) Create Git user</h3> +<blockquote> +<p># adduser git</p> +</blockquote> +<hr> +<h3>3) Now you need to add your SSh keys</h3> +<p>On computer</p> +<blockquote> +<p>$ ssh-copy-id git@server_ip</p> +</blockquote> +<p>If you want to allow other people to use your Git server, add their SSH keys alongside yours.</p> +<p>On server:</p> +<blockquote> +<p># su git<br> +$ cd<br> +$ mkdir .ssh && chmod 700 .ssh<br> +$ touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys</p> +</blockquote> +<hr> +<h3>4) Nearly done, now all you need to do is make a git repo.</h3> +<blockquote> +<p># mkdir -p /srv/git<br> +# chown git:git /srv/git<br> +# su git<br> +$ cd /srv/git<br> +$ mkdir yourrepo.git<br> +$ cd yourrepo.git<br> +$ git init --bare</p> +</blockquote> +<hr> +<h3>5) Add your server to your local repo</h3> +<p>On computer</p> +<blockquote> +<p>$ cd yourrepo<br> +$ git init<br> +$ git add .<br> +$ git commit -m 'Initial commit'<br> +$ git remote add origin git@gitserver:/srv/git/project.git<br> +$ git push origin master</p> +</blockquote> +<p>If you already have a Git repository from another server, you can do the following to add your new Git server alongside your old one.</p> +<blockquote> +<p>$ cd yourrepo<br> +$ git remote add server git@gitserver:/srv/git/project.git<br> +$ git push server master && git push origin master</p> +</blockquote> +<hr> +<h3>6) If you want to enable anybody to clone from your website do the following!</h3> +<blockquote> +<p># sudo git daemon --reuseaddr --base-path=/srv/git/ /srv/git/ &<br> +# sudo systemctl enable git-daemon<br> +# sudo systemctl start git-daemon<br> +# su git<br> +# touch /srv/git/project.git/git-daemon-export-ok</p> +</blockquote> +<p>Cloning your git repo</p> +<blockquote> +<p>git clone git://your-server-ip-address/repository.git</p> +</blockquote> +<p>Now you should be able to be able to clone without a ssh key!</p> +<hr> +<h1>Setting up Stagit for personal git website</h1> +<p>Now that you have a Git server, you probably want a way to show off all of your repositories. I personally use Stagit for this because it is lightweight and stylish. I will assume you know how to make a website using Apache or Nginx.</p> +<hr> +<h3>1) First you need to install stagit (I have my own custom fork to make it easier to setup)</h3> +<blockquote> +<p># cd /var/www<br> +# git clone git://shipwreckt.co.uk/Stagit.git<br> +# mkdir git<br> +# chown git:git git<br> +# mv stagit-fork/* git<br> +# cd git<br> +# sudo make clean install</p> +</blockquote> +<hr> +<h3>2) Setup website.</h3> +<blockquote> +<p># cd htmldir<br> +# sh example_create.sh</p> +</blockquote> +<p>Your static stagit website should be generated for you! Check by going to git.yourdomain.com.</p> +<hr> +<h3>3) Next you want to set up ownership, links, and descriptions for stagiit to display</h3> +<p>Descriptions</p> +<blockquote> +<p># This is my git repo > /srv/git/yourrepo.git/description</p> +</blockquote> +<p>URL</p> +<blockquote> +<p># git://yourdomain.com/yourrepo.git > /srv/git/yourrepo.git/url</p> +</blockquote> +<p>Owner</p> +<blockquote> +<p># owner > /srv/git/yourrepo.git/owner</p> +</blockquote> +<p>Update stagit</p> +<blockquote> +<p># sh /var/www/git/htmldir/example_create.sh</p> +</blockquote> +<p>Now repete for all of your repos till all is correct!</p> +<hr> +<h3>3) Now you want it so stagit updates whenever there is an update, thankfully for you I have modified the script to work whenever a git commit is made!</h3> +<blockquote> +<p># cp /var/www/git/example_post-receive.sh /srv/git /srv/git/yourgitrepo.git/hooks/post-receive</p> +</blockquote> +<p>Now whenever you push a commit everything should update!</p> +<hr> +<h1>Overview</h1> +<p>I hope this guide has helped you setup a kool git server! If there are any problems please contact me!</p> + + </div> + </article> + + + + + <footer> + <a href="/archive/linux" class="back-button">⬅ Back to Linux</a> + </footer> + + </body> +</html> + |
