Skip to main content

Home/ WikiTechie/ Group items tagged linux

Rss Feed Group items tagged

Muhammad Al-Syrwan

How to set up your own private Git server on Linux | Bradley Wright - 0 views

  •  
    ssh myserver.com sudo apt-get update sudo apt-get install git-core …and that's it. Adding a user If you intend to share these repositories with any collaborators, at this point you'll either: Want to install something like Gitosis (outside the scope of this article, but this is a good, if old, tutorial); or Add a "shared" Git user. We'll be following the latter option. So, add a Git user: sudo adduser git Now you'll need to add your public key to the Git user's authorized_keys: sudo mkdir /home/git/.ssh sudo cp ~/.ssh/authorized_keys /home/git/.ssh/ sudo chown -R git:git /home/git/.ssh sudo chmod 700 !$ sudo chmod 600 /home/git/.ssh/* Now you'll be able to authenticate as the Git user via SSH. Test it out: ssh git@myserver.com Add your repositories If you were to not share the repositories, and just wanted to access them for yourself (like I did, since I have no collaborators), you'd do the following as yourself. Otherwise, do it as the Git user we added above. If using the Git user, log in as them: login git Now we can create our repositories: mkdir myrepo.git cd !$ git --bare init The last steps creates an empty repository. We're assuming you already have a local repository that you just want to push to a remote server. Repeat that last step for each remote Git repository you want. Log out of the server as the remaining operations will be completed on your local machine. Configure your development machine First, we add the remotes to your local machine. If you've already defined a remote named origin (for example, if you followed GitHub's instructions), you'll want to delete the remote first: git remote rm origin Now we can add our new remote: git remote add origin git@server.com:myrepo.git git push origin master And that's it. You'll probably also want to make sure you add a default merge and remote: git config branch.master.remote origin && git config branch.master.merge refs/heads/master And that's all. Now you
1 - 1 of 1
Showing 20 items per page