Sites like Github, Bitbucket, and GitLab make it ridiculously easy to setup public and private remote repos, which might make a lot of sense for your team. Sometimes there is an added cost to this though, whether financially or simply introducing another third-party dependency into your project.
Setting up your own git repo is easy and allows you to host your versioning system on your own server.
Getting started on the remote server
We'll need to set up a dedicated user to manage the repos.
su - // Enter super user
adduser git // Create the new user with home directory
su git // Login as that user
cd ~/ && mkdir .ssh
On the client
Optional: Installing ssh-copy-id
ssh-copy-id is a handy package that allows you to copy your local machine's public key to the authorized_keys file on the remote machine.
I use the homebrew package manager on macOS which, if you don't, you can find more information on at http://brew.sh/
brew install ssh-copy-id
ssh-keygen -C "email@example.com" // Generate a new rsa key
ssh-copy-id <user@server> // Copies rsa keys to the authorized_keys file on the host
mkdir gitDirectory // Create folder for wherever you'll want the git repo
cd gitDirectory && git clone user@server:<repo.git>
git pull origin <branch> // or do an initial commit and push it up to the server
To push a branch up to the server:
git checkout -b feature_branch_name
- ... edit files, add and commit ...
git push -u origin feature_branch_name
And that's it. You have a remote repo that you and your team can use, have full control over, and with no added cost. Happy coding!