Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
technical:hosting_your_own_git [2025/05/27 06:07] – super_stunder | technical: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. | + | //Hope this helps you out. I wasn't a huge fan of github even before it became owned by Microsoft. |
//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/ | + | :!: //I guess this is a good time to point out in Linux and in most things software/ |
//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. | + | Now on my home_pc or laptop I just use my home directory because that is where I keep most of my coding projects. |
- | <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 / | [laptop]$ cd / | ||
[laptop]$ git init | [laptop]$ git init | ||
Initialized empty Git repository in / | Initialized empty Git repository in / | ||
[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. | + | This will give you an empty git repository on your local machine. Now you can load your cli or whatever into this directory. |
- | <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 " | [laptop]$ git commit -m " | ||
Line 67: | Line 67: | ||
1 file changed, 0 insertions(+), | 1 file changed, 0 insertions(+), | ||
| | ||
- | </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:// | git remote add origin ssh:// | ||
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: | nugget@gitshed: | ||
nugget@gitshed: | nugget@gitshed: | ||
- | </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: | nugget@gitshed: | ||
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] | * [new branch] | ||
branch ' | branch ' | ||
- | </code> | + | </cli> |
+ | |||
+ | ** 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. | ||
+ | |||
+ | < | ||
+ | nugget@kalin-nugget: | ||
+ | nugget@kalin-nugget: | ||
+ | nugget@kalin-nugget: | ||
+ | Cloning into ' | ||
+ | remote: Enumerating objects: 3, done. | ||
+ | remote: Counting objects: 100% (3/3), done. | ||
+ | Receiving objects: 100% (3/3), done. | ||
+ | remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 | ||
+ | nugget@kalin-nugget: | ||
+ | demo_file.txt | ||
+ | </ | ||
+ | |||
+ | At the end you should be able to list the directory and have the exact same files you have on your other system. | ||