Skip to content

Instantly share code, notes, and snippets.

@dattasaurabh82
Last active April 22, 2024 13:25
Show Gist options
  • Save dattasaurabh82/d864ff7f13f9849d4946e1bc221401f2 to your computer and use it in GitHub Desktop.
Save dattasaurabh82/d864ff7f13f9849d4946e1bc221401f2 to your computer and use it in GitHub Desktop.
How to setup your own git server and not use microsoft's github

Hoping you have your own VPS setup by now

SSH into GIT SERVER: you can either create a new user or remain root and give other also root priviledges [dangerous]

ssh root@<Your server's IPV4 addr or domain>
# or 
ssh <new-user>@<Your server's IPV4 addr or domain>

optionally you can also add your ssh public key to the git server

ON GIT SERVER : For creating a new git repo:

mkdir /gits
cd /gits
git init --bare <your-project-name>.git

ON CLIENT SIDE: For pushing first time: [cd into your project dir]

git init
git add .
git commit -m “commit message” -a
git remote add origin root@<Your server's IPV4 addr or domain>:/gits/<your-project-name>.git
or 
git remote add origin <new-user>@<Your server's IPV4 addr or domain>:/gits/<your-project-name>.git
git push -u origin master

Note: Have a readme file, license file and gitignore file. These help!

For cloning an existing project

git clone root@<Your server's IPV4 addr or domain>:/gits/<your-project-name>.git
# or 
git clone <new-user>@<Your server's IPV4 addr or domain>:/gits/<your-project-name>.git

You know how to fork and all that stuff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment