DEV Community

Cover image for I stopped relying on Github!
Arma Sahar
Arma Sahar

Posted on

I stopped relying on Github!

What is a server?
Server means which listens to request coming from a different computer and responds back to the request.

For example:
You go and search on Google, that means you are making a request from your system to Google's server.

armasahar

Then from somewhere another computer replies:
armasahar

As the web pages are hosted on Google, you get a response back from Google's server. That computer which listens, processes, and responds is the "server"!

Servers differ based on what they serve

Like Web Server - serves Web pages, File server - Lets you store and access files, Database server - Stores and manages structured data, in the same way
GIT SERVER Stores git repositories and handles push/pull requests just like how Github does.

The difference between all of these is just the software we use to build a server and port number.

So today I am going to make my own Git Server, but why do I need it in the first place? What's the importance of having our own Git servers?

Recently we have been hearing a lot about many vibe coders are pushing their API keys on Github repositories.

And also what if Github crashes what are you gonna do?

Have you ever seen large companies push their codes on Github? Where do they store their codebases?

Think...think... till then I will make my Git server and share my point of view.

Oh by the way!
A general Question: What is the significance of "Origin"
what is mean by origin in git command
Comment down the answer below!

I am going to use my Virtual Machine as my Git Server and from my local terminal, I'll access the server to push and pull the code.

Note: Before starting with Git server setup, I created a separate user called as Git & Generated SSH key for it.

Step 1: Switch the user to git

git server

Step 2: Check if you have Git installed

git server

Step 3: Create a directory for the git server and go to that directory

git server

That's it this is going to be that space where you are going to create a new repository and push the code here. Just in case if you are wondering how is it going to work, then let me clarify;

What is a Repository?
It is just a folder on Github, ain't it? So just like how we go and create a new repo on Github we do it here locally.

Step 4: Initialise a bare git repository

git server

This will create

/home/gitserver/myFirstRepo.git/
├── branches/
├── config
├── description
├── HEAD
├── hooks/
├── info/
└── refs/
Enter fullscreen mode Exit fullscreen mode

Now as I have setup the Git server on my Virtual Machine, I will be connecting to it via SSH.

ssh git@<Virtual Machine's IP Address
I made sure you have ssh enabled and active on the virtual Machine.

Once I get connected I will be shown like this on my local terminal (!Virtual Machine)

git server

This is just to check if my local machine is able to access my SSH connection from my Virtual Machine.

Now I am going to push few files from my local terminal to the Git server. Currently I am here:

git server

Now I am going to follow the same git commands, which we use to push the code on Github.

I have initialised git in my directory

git server

The next step is we add the remote repository (git-server's path) to the folder. Now watch carefully when I add the repository, their's a slight difference in it:

git server

TA DAAA!!

git server

Did you notice that I didn't use git remote add "origin", instead I chose to write gitServer. That means Origin has no specific significance neither it is by default. Its like a variable name for your repository.

Okay so final test of this server! Let's check if I can push the code.

The OG commands:
Git add && git commit:
git server

and Now I am going to push it into the repository which is on Git server

git server

Let's check!!

Here you go, my repo has been updated with the pushed code!
git server

As this was my first commit on the bare repository hence I did not had to merge.

So why make your own Git server?
Because using GitHub is convenient, but it’s still someone else’s computer right!?

When you push code to GitHub, you’re trusting them with everything: their servers to stay online, their policies not to change, their security to keep your data private.

If GitHub deletes your repo by any chance, it’s gone unless you’ve backed it up.

Having your own Git server means; you have control over backups, you decide who can access it, you decide when to update or migrate.

I have mentioned above about “vibe coders pushing their API keys!”

That’s exactly why public Git hosting is risky: Git’s history is permanent.. even if you delete a key, it’s still available somewhere in previous commits.

Or attackers use bots that scans GitHub in real time for exposed .env or API keys. Once compromised, attackers can steal data, send emails, or any other kind of malicious activity

Anything can happen, so safe side have your own git server and for backup or secondary source use Github.

Thanks for reading!

Top comments (0)