Git

All the Git things in here.

Using SSH

Client device needs to have correct SSH key and configuration for this way to work.

Create new repository via Gitea webapp, then do:

git init
git config user.email "git@zcyph.cc"
git config user.name "zcyph"
git add *
git commit -m 'initial'
git push gitea:zcyph/repoName

Using a token

To avoid storing SSH key on remote clients, first create a personal access token from within the Gitea webapp.

git init
git config user.email "git@zcyph.cc"
git config user.name "zcyph"
git add *
git commit -m 'initial'
git remote add origin https://git.zcyph.cc/zcyph/privacyroot.org.git
git push -u origin master

Then enter the personal access token as the password.

Multiple identities

Make sure you've created an SSH key and told Git about it. Check with ssh-add -l to be sure the key appears there. If not, do ssh-add /path/to/ssh/key.

If ssh-agent is not running, do: eval "$(ssh-agent -s)".

To use multiple identities, edit ~/.ssh/config and add an entry for each:

Host gomarcd.github.com
    Hostname github.com
    User gomarcd
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/github-gomarcd
    IdentitiesOnly yes

Host gomarcd.codeberg.org
    Hostname codeberg.org
    User gomarcd
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/banoshi-codeberg-gomarcd
    IdentitiesOnly yes

Then tell the Git repo you're working in to use the right host with nano .git/config:

[remote "origin"]
        url = git@gomarcd.codeberg.org:gomarcd/quickphp.git
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = git@gomarcd.github.com:gomarcd/quickphp.git

Also include your identity and to sign using your GPG key:

[user]
        name = gomarcd
        email = git@gomarcd.dev
        signingkey = F7FA7CBDCC32ECA6
[commit]
        gpgsign = true

git@gomarcd.dev will need to be claimed in each remote (Github and Codeberg in this case).

Multiple repos and GPG signing

To push to multiple repos and automatically sign commits with PGP, use this as a .git/config in the project directory and make sure it corresponds to the correct ssh and gpg identities:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = git@gomarcd.dev:gomarcd/supman
        url = git@gomarcd.codeberg.org:gomarcd/supman
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = git@gomarcd.github.com:gomarcd/supman
        url = git@gomarcd.sr.ht:~gomarcd/supman
[branch "main"]
        remote = origin
        merge = refs/heads/main
[user]
        name = gomarcd
        email = git@gomarcd.dev
        signingkey = F7FA7CBDCC32ECA6
[commit]
        gpgsign = true
[pull]
        rebase = false

Tags

In Crashtest, we are pushing releases using tags. It's important to make sure you are using a new tag, or have first deleted the existing tag before pushing, otherwise your workflow pipeline could be unwittingly running off an older release.yml.

Delete tag:

git tag -d v0.0.1

Then push new one:

git tag -s v0.0.1 -m "Release 2025.0.0.1" && git push origin v0.0.1