technical:hosting_your_own_git

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
technical:hosting_your_own_git [2025/05/27 15:33] – added step 6 super_stundertechnical:hosting_your_own_git [2025/06/04 01:24] (current) – changing code blocks to cli blocks super_stunder
Line 1: Line 1:
 ====== Hosting your own git repos ====== ====== Hosting your own git repos ======
-//Hope this helps you out.  I wasn't a huge fan of github even before it became owned by Microsoft.  These days I think there are [[https://simonwillison.net/2025/May/26/github-mcp-exploited|enough reasons]] to host your own git repos.  It's honestly pretty simple an free. I think I first started questioning hosting all of my code/projects at github when their site came under a [[https://www.wired.com/story/github-ddos-memcached/|state sponsored DDoS attack]]. We were a small SaaS startup with a dev heavy staff. During this attack the whole office stopped pretending to work and actually just blatantly started goofing off.//+//Hope this helps you out.  I wasn't a huge fan of github even before it became owned by Microsoft.  These days I think there are [[https://simonwillison.net/2025/May/26/github-mcp-exploited|enough reasons]] to host your own git repos.  It's honestly pretty simple an free. I think I first started questioning hosting all of my cli/projects at github when their site came under a [[https://www.wired.com/story/github-ddos-memcached/|state sponsored DDoS attack]]. We were a small SaaS startup with a dev heavy staff. During this attack the whole office stopped pretending to work and actually just blatantly started goofing off.//
  
 //After that DDoS I started looking for github alternatives and figured out that you can use git itself to just host your own repos. So these days I keep my own gitserver at Digital Ocean. This allows me to control my own uptime and not leave my repos out there for Microsoft to do whatever they want with it.// //After that DDoS I started looking for github alternatives and figured out that you can use git itself to just host your own repos. So these days I keep my own gitserver at Digital Ocean. This allows me to control my own uptime and not leave my repos out there for Microsoft to do whatever they want with it.//
Line 23: Line 23:
 Install git, I just used the default git install from the apt repositories. Be sure you install this on all of your devices (gitshed, home_pc, and laptop) Install git, I just used the default git install from the apt repositories. Be sure you install this on all of your devices (gitshed, home_pc, and laptop)
  
-<code>+<cli>
 sudo apt install git sudo apt install git
-</code>+</cli>
  
 There are a ton of git related tools in the default Debian apt repos but this should be all you need to get started.  There are a ton of git related tools in the default Debian apt repos but this should be all you need to get started. 
  
  
-:!: //I guess this is a good time to point out in Linux and in most things software/commercial hardware there are a lot of ways to do things.  In my case I am the only person using my repos, I am not setting this up for multiple users but you can do a couple of tricks with building a git user/service account and let multiple users push/pull code from that directory.  If I went that far I would probably enforce individual user accounts.  But like I said a lot of ways to do things.//+:!: //I guess this is a good time to point out in Linux and in most things software/commercial hardware there are a lot of ways to do things.  In my case I am the only person using my repos, I am not setting this up for multiple users but you can do a couple of tricks with building a git user/service account and let multiple users push/pull cli from that directory.  If I went that far I would probably enforce individual user accounts.  But like I said a lot of ways to do things.//
  
 //With that being said lets get on to step 3// //With that being said lets get on to step 3//
Line 36: Line 36:
 **Step 3: Setting up local repos ** **Step 3: Setting up local repos **
  
-Now on my home_pc or laptop I just use my home directory because that is where I keep most of my coding projects.  I mean why in the world would I keep it in var or opt? (sorry bad nerd joke). You can name the projects how ever you'd like I just usually go with something like repos, projects, or code.  Under that directory is where I keep all of the different projects I am working in here we just call it repo1 and repo2+Now on my home_pc or laptop I just use my home directory because that is where I keep most of my coding projects.  I mean why in the world would I keep it in var or opt? (sorry bad nerd joke). You can name the projects how ever you'd like I just usually go with something like repos, projects, or cli.  Under that directory is where I keep all of the different projects I am working in here we just call it repo1 and repo2
  
-<code>+<cli>
 [laptop]$ mkdir repos [laptop]$ mkdir repos
 [laptop]$ cd repos [laptop]$ cd repos
 [laptop]$ mkdir repo1 repo2 [laptop]$ mkdir repo1 repo2
-</code>+</cli>
  
 Now in the repos directory you can initialize the repository Now in the repos directory you can initialize the repository
  
-<code>+<cli>
 [laptop]$ cd /home/nugget/repos/repo1 [laptop]$ cd /home/nugget/repos/repo1
 [laptop]$ git init [laptop]$ git init
 Initialized empty Git repository in /Users/nugget/repos/repo1/.git/ Initialized empty Git repository in /Users/nugget/repos/repo1/.git/
 [laptop]$ [laptop]$
-</code>+</cli>
  
-This will give you an empty git repository on your local machine. Now you can load your code or whatever into this directory.  For the case of this example we will just touch an empty file and add a comment.+This will give you an empty git repository on your local machine. Now you can load your cli or whatever into this directory.  For the case of this example we will just touch an empty file and add a comment.
  
-<code>+<cli>
 [laptop]$ touch demo_file.txt [laptop]$ touch demo_file.txt
-</code>+</cli>
  
 Now you can commit the file to your local repo.  You can use other methods this is just to get us through the demo. Now you can commit the file to your local repo.  You can use other methods this is just to get us through the demo.
  
-<code>+<cli>
 [laptop]$ git add -A [laptop]$ git add -A
 [laptop]$ git commit -m "Initialize repository" [laptop]$ git commit -m "Initialize repository"
Line 67: Line 67:
  1 file changed, 0 insertions(+), 0 deletions(-)  1 file changed, 0 insertions(+), 0 deletions(-)
  create mode 100644 demo_file.txt  create mode 100644 demo_file.txt
-</code>+</cli>
  
-Now you will need to tell your local git where you will push code to remotely.+Now you will need to tell your local git where you will push cli to remotely.
  
-<code>+<cli>
 git remote add origin ssh://nugget@gitshed.igazine.com:/home/nugget/repos/repo1/repo1.git git remote add origin ssh://nugget@gitshed.igazine.com:/home/nugget/repos/repo1/repo1.git
 git branch -M main git branch -M main
-</code>+</cli>
  
 Before you can push to the remote repo you need initialize a bare repo on the git server.  Before you can push to the remote repo you need initialize a bare repo on the git server. 
Line 82: Line 82:
 On the Git Server you can add the bare repo. On the Git Server you can add the bare repo.
  
-<code>+<cli>
 nugget@gitshed:~$ mkdir -p repos/repo1 nugget@gitshed:~$ mkdir -p repos/repo1
 nugget@gitshed:~$ git init --bare repos/repo1/repo1.git nugget@gitshed:~$ git init --bare repos/repo1/repo1.git
-</code>+</cli>
  
 If you want to verify the .git repo is in the directory you can  If you want to verify the .git repo is in the directory you can 
  
-<code>+<cli>
 nugget@gitshed:~$ ls -la repos/repo1 nugget@gitshed:~$ ls -la repos/repo1
 total 24 total 24
Line 95: Line 95:
 drwxr-xr-x 4 nugget nugget 4096 Mar 18 03:45 .. drwxr-xr-x 4 nugget nugget 4096 Mar 18 03:45 ..
 drwxr-xr-x 7 nugget nugget 4096 May 27 05:54 repo1.git drwxr-xr-x 7 nugget nugget 4096 May 27 05:54 repo1.git
-</code>+</cli>
  
 ** Step 5: back to the Local Device ** ** Step 5: back to the Local Device **
-Now if you have done all of the other steps correctly you should be able to simply push code from your laptop to the server.+Now if you have done all of the other steps correctly you should be able to simply push cli from your laptop to the server.
  
-<code>+<cli>
 [laptop]$ git push -u origin main [laptop]$ git push -u origin main
 Enumerating objects: 3, done. Enumerating objects: 3, done.
Line 109: Line 109:
  * [new branch]      main -> main  * [new branch]      main -> main
 branch 'main' set up to track 'origin/main'. branch 'main' set up to track 'origin/main'.
-</code>+</cli>
  
 ** Step 6: Testing from your other devices ** ** Step 6: Testing from your other devices **
 Alright you were able to connect things from one of your devices to a git repo you built out in the cloud some place.  Now you want to check things with your other devices in this case I will use my home PC this can be done easily with a simple clone of the repo.   As long as you have ssh keys and accounts synced up (just like above) this should just work.  You may want to copy into a local "repos" directory just to keep things consistent in your dev environments.  Alright you were able to connect things from one of your devices to a git repo you built out in the cloud some place.  Now you want to check things with your other devices in this case I will use my home PC this can be done easily with a simple clone of the repo.   As long as you have ssh keys and accounts synced up (just like above) this should just work.  You may want to copy into a local "repos" directory just to keep things consistent in your dev environments. 
  
-<code>+<cli>
 nugget@kalin-nugget:~$ mkdir repos nugget@kalin-nugget:~$ mkdir repos
 nugget@kalin-nugget:~$ cd repos nugget@kalin-nugget:~$ cd repos
Line 125: Line 125:
 nugget@kalin-nugget:~$ ls repo1 nugget@kalin-nugget:~$ ls repo1
 demo_file.txt demo_file.txt
-</code>+</cli>
  
-At the end you should be able to list the directory and have the exact same files you have on your other system.  You can figure out git workflows and collaboration if you check out the [https://www.learnenough.com/git|Learn Enough GIT]] classes like I mentioned above. +At the end you should be able to list the directory and have the exact same files you have on your other system.  You can figure out git workflows and collaboration if you check out the [[https://www.learnenough.com/git|Learn Enough GIT]] classes like I mentioned above. 
  
  
  • technical/hosting_your_own_git.1748359999.txt.gz
  • Last modified: 2025/05/27 15:33
  • by super_stunder