Add project repository to Gitlab
If you want to install your project elsewhere (like on your local computer) and exchange edits with the live version, then you'll want to host your Git repository online somewhere. All project locations can then push and pull from that central repository, so each installation will always have access to the latest data.
You probably don't want this data to be accessible by anyone else, however. So you need the central repository to be private. There are several providers for private Git repositories, such as Github and Bitbucket, but we decided to use Gitlab for this purpose. Gitlab offers unlimited private repositories for free, together with a bunch of other features that you might find interesting.
Create an account on Gitlab
Obviously, you need to have an account. Go to https://gitlab.com/ and sign up.
Create a private repository
This means: create a new project and make sure access permissions are set to private. Copy the 'Clone via SSH' link when you're done.
Add SSH key to Gitlab
Now go back to your server. Generate an SSH key as your projects' local user:
sudo chown project-user:project-user /home/project-folder/.ssh
sudo -i -u project-user ssh-keygen -t ecdsa -b 521
Press enter when asked in which file to save and twice when asked for a passphrase. Then:
cat /home/project-folder/.ssh/id_ecdsa.pub
Copy the output of this command (which is your new public key) and add it to Gitlab as Deploy Key. In your project on Gitlab, go to Settings > Repository > Deploy keys. If you are installing the project on your localhost also, make sure 'Write permissions' is checked, so you can merge changes from your localhost with the live project.
Add Gitlab repository as remote
We're ready now to deploy our local repository to Gitlab! Go back to the project root on your server and add the Gitlab location as remote:
git remote add origin [email protected]:fractal-farming/your-project.git
And the final push:
git push -u origin master