From c9400541171825d01b8cd30a1c1f647e64a21827 Mon Sep 17 00:00:00 2001 From: TillDiem Date: Sun, 2 Jan 2022 09:57:02 +0100 Subject: [PATCH] Added GIT --- TODO.md | 2 +- docs/GIT.md | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++ docs/ssh.md | 5 +--- index.md | 1 + 4 files changed, 89 insertions(+), 5 deletions(-) create mode 100644 docs/GIT.md diff --git a/TODO.md b/TODO.md index ae0dd80..acf62c1 100644 --- a/TODO.md +++ b/TODO.md @@ -1,4 +1,4 @@ # General - [ ] create a script as a wrapper to these docs similar to tldr/kb -- [ ] create wrapper script for md to html export +- [X] create wrapper script for md to html export - Maybe usage of bundestag wrapper scrips? diff --git a/docs/GIT.md b/docs/GIT.md new file mode 100644 index 0000000..0871452 --- /dev/null +++ b/docs/GIT.md @@ -0,0 +1,86 @@ +# General + +GIT is a version control software, that allows you to save the progress of software/text/whatever development. +It is probably best know from GitHub, but we will show how to set up your own GIT instance and how to use it. + +## Installing GIT + +### What you need + +1. A working server, being it self-hosted at home or a remote instance, called REMOTE in the following +2. A local machine that you develop whatever on, called LOCAL in the following + +### Installing GIT + +On the LOCAL machine, use your favorite package manager, for example + +```sh +pacman -S git +``` + +The same holds for the REMOTE machine, but here I would advice, to use some LTS distro, so probably + +```sh +sudo apt install git +``` + +### Setting up the Server + +First we have to add the git-user on the REMOTE, give him a password and enable ssh logins. + +```sh +sudo adduser git +su git +passwd +cd +mkdir .ssh & chmod 700 .ssh +touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys +``` +Now add the ssh public keys of your LOCAL machine to the `authorized_keys` file on the REMOTE. +For this on the LOCAL machine generate a key-pair using `ssh-keygen -t rsa` if you don't have one yet. +Then copy the content of `LOCAL/.ssh/id_rsa.pub` to the `REMOTE/.ssh/authorized_keys` file. + +## New Repository + +To initialize a repository on the REMOTE server we have to create a new folder and tell git to track this folder. +This has to be done once for every new repository. + +```sh +cd +mkdir NewRepo.git +cd NewRepo.git +git init --bare +``` + +On the LOCAL machine we then have to create a folder and tell git to sync this with the server. +We will assume that `REMOTE` is either the IP or the domain-name of the REMOTE instance. + +```sh +cd project +git init +git add . +git commit -m 'Initial commit' +git remote add origin git@REMOTE:/home/git/NewRepo.git +git push origin master +``` + +## Using Git + +To now sync this folder to other devices use + +```sh +git clone git@gitserver:/home/git/NewRepo.git +cd project +``` + +To update the repository go to the folder, add the necessary files using `git add ` and then commit them using `git commit -m '`. These steps can be done as one using + +```sh +git commit -am 'Fix for README file' +``` + +Now push it to the server using `git push origin master`. + +### Further Info + +- [Git Website](https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server) diff --git a/docs/ssh.md b/docs/ssh.md index 38844ff..c3ba703 100644 --- a/docs/ssh.md +++ b/docs/ssh.md @@ -1,6 +1,4 @@ # General - -SSH is a helper utensil to connnect to remote servers. The basic syntax is ``` ssh user@domain @@ -19,8 +17,7 @@ Change the permisions of this folder using `chmod 700 ~/.ssh`. The next step is to make the `authorized_keys` file using ``` touch ~/authorized_keys -chmod 600 ~/.ssh/authorized_keys -``` +chmod 600 ~/.ssh/authorized_keys ``` Now open the `authorized_keys` and copy-paste the public key contents in to it. One can also use `ssh-copy-id user@domain` after generating the key-pair. diff --git a/index.md b/index.md index 54f554e..04bf3c8 100644 --- a/index.md +++ b/index.md @@ -10,6 +10,7 @@ Happy to accept pull requests for new topics! A wiki script for vim - [weechat](docs/weechat.md) A TUI client for matrix - [ssh](docs/ssh.md) ssh configuration +- [GIT](GIT) A version control software # Admin