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?
CodePudding user response:
Yes, what you are looking for is a Git server.
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 core:
sudo apt-get install git-core
- Create a user:
sudo useradd git
- 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>
CodePudding user response:
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.
CodePudding user response:
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.