Tag Archive : GIT

/ GIT

Shell

Congratulations on using a Version Control System for your code! Believe it or not, not everyone is, well, let’s say, “informed” enough to do it. You’re probably also using GitHub, which is great too. Especially since they now offer private repositories for free.

It’s not always the case, however, that you want to use a solution like GitHub, BitBucket, etc. Sometimes you’re work requirements are such that you’re code is all kept internally to your work network and you need to set up your own remotes. Here is how you do it.

On the server that will host your repos you will need to create a directory to contain them all, create the bare repository for your project then initialize the empty repo. Lets say your repository directory will live off of root and be named git.

$ mkdir /git
$ mkdir /git/my-repo.git && cd /git/my-repo.git
$ git --bare init

Your empty repository is ready to go, so go back to your workstation. Replace username and host with your username and the dns name or ip address of the remote server.

$ git remote add origin username@host:/git/my-repo.git
$ git push origin master

And that’s it. You have have a remote repository under your control.