Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a git remote?

Tags:

git

git-remote

I'm not talking about git remote add, I'm talking about actually creating "the remote", like one on GitHub, the one you have to add with git remote add. From what I know a remote is just another copy of a repo, but it's stored on some dedicated machine. I want to try hosting something like that on my local network, so I can have bootleg GitHub at home. Is it possible?

like image 459
The Developer Avatar asked May 14 '26 02:05

The Developer


2 Answers

Git doesn't even need a dedicated "server" when working over SSH.

If you have shell access and appropriate permissions, you can run git init --bare in an empty directory to turn it into a Git repository. Then you can add username@hostname:path/to/dir as a Git remote and do your normal pulls and pushes, leveraging your normal SSH access, including any host aliases and config defined in ~/.ssh/config.

If you're only looking to storing your code on a remote server this is the easiest way to go.

like image 92
iBug Avatar answered May 18 '26 16:05

iBug


Yes, what you are looking for is a Git "server".

The double quotes are, as others mentioned it as well, because Git doesn't really require an instance running as a server. Every Git repository is a "server" you can clone.

However, if you search for "run git server locally" in Google, you'll find plenty of results.

Referencing some of the steps from one easy example:

  • Install git on the machine: sudo apt-get install git-core
  • Create a dir for the repo: mkdir -p $HOME/project-1.git
  • Go to that dir: cd $HOME/project-1.git
  • Initialize the repo: git init --bare
  • Add the repo as a remote: git remote add origin ssh://git@remote-server/<path>
like image 45
Daniel Trugman Avatar answered May 18 '26 14:05

Daniel Trugman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!