git

Self-Hosting

https://about.gitlab.com/install/#ubuntu

Gitea

act_runner (Action)

Download runner

Binary: https://dl.gitea.com/act_runner/ Docker image: https://gitea.com/gitea/act_runner#run-with-docker

Acquire Token

Version 1.19.* get toket at: <your-domain>/admin/runners

Version 1.21.* get toket at: <your-domain>/user/settings/actions/runners

./act_runner register

Note

if you want to run the action directly on your hardware, without docker in between, set host as the runner label.

After succedfull registration, you can run the act_runner using the following command.

./act_runner daemon

To start the runner after every reboot, edit your crontab accordingly. Make sure to change in the directory where your config is located and start the runner from there…

@reboot (cd /your/directory/ && /your/directory/act_runner-0.2.10-linux-amd64 daemon)

Clone Git-Repo with Access Token

Create Token for accesing the registry under https://<your-gitea-instance>/user/settings/applications Be sure to allow Read/Write Access to the repository and package.

To check all tokens with their scope run the following command.

git clone https://<user>:<key>@gitlab.com/<user>/<project>.git

this should return something similar to the following

[
   {
      "id": <your-id>,
      "name": "<your-name>",
      "sha1": "",
      "token_last_eight": "<part-of-your-token>",
      "scopes": [
         "read:misc",
         "read:notification",
         "read:organization",
         "write:package",
         "read:issue",
         "write:repository",
         "read:user"
      ]
   },
   ...
]

Get tag of current commit

git describe --tags --always | sed 's/^v//'

Use Gitea Registry

curl -X GET -u <user>:<password> https://<your-gitea-instance>/api/v1/users/<user>/tokens | jq

Show remote URL of repository

git remote -v

Show set (remote) URL of repository

git remote set-url origin new.git.url/here

The Perfect Commit

git add -p <filename> # To add files on the patch level (add only parts of the changes of one file)

This lets you choose one path out of a status like selection. After choosing the path, it presents the diff between the index and the working tree file and asks you if you want to stage the change of each hunk. You can select one of the following options and type return:

y - stage this hunk n - do not stage this hunk q - quit; do not stage this hunk nor any of the remaining ones a - stage this hunk and all later hunks in the file d - do not stage this hunk nor any of the later hunks in the file g - select a hunk to go to / - search for a hunk matching the given regex j - leave this hunk undecided, see next undecided hunk J - leave this hunk undecided, see next hunk k - leave this hunk undecided, see previous undecided hunk K - leave this hunk undecided, see previous hunk s - split the current hunk into smaller hunks e - manually edit the current hunk ? - print help

Remove files from git, which are in .gitignore but have been added previously

Selected files

git rm --cached file1 file2 dir/file3

All files from .gitignore

git rm --cached `git ls-files -i -c --exclude-from=.gitignore`

Reset to last Commit

Single file

git checkout <fileName>

Whole Project

git reset --hard <hash>

Uncommit without removing changes

git reset --soft HEAD^

Set file acces flags to already commited file

To set the flag, use following command: .. code-block:: bash

git update-index –chmod=+x path/to/file

To remove it, use:

git update-index --chmod=-x path/to/file

Find largest files in git repo

git ls-tree -r -t -l --full-name HEAD | sort -n -k 4 | tail -n 10

Clone with depth

git clone --depth 1 https://git-server.com/user/repo.git

Runners

Gitlab-Setup