The Developer
The Developer

Reputation: 379

How to create a 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?

Upvotes: 2

Views: 3192

Answers (3)

Daniel Trugman
Daniel Trugman

Reputation: 8501

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>

Upvotes: 2

Aleksandr Medvedev
Aleksandr Medvedev

Reputation: 8978

The remote concept of git actually refers to any remote repository, it doesn't need to be some kind of specific server. So if you just create a repo locally on your machine, it can be added as a remote for another git repo.

Upvotes: 1

iBug
iBug

Reputation: 37227

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.

Upvotes: 4

Related Questions