Notes, mainly for working on sourcehut. I keep forgetting some of these commands and it’s nice to have a reference.
$ eval ""
Typically stored at ~/.ssh/
ssh-keygen -t ed25519 -f ~/.ssh/KEYNAME -C "COMMENT"
$ ssh-add ~/.ssh/KEY_NAME
For example, to ssh into a web host:
ssh-copy-id -i ~/.ssh/KEYNAME.pub USER@DOMAIN.COM
This will ask for the user’s password, so that it can ensure the key is being loaded by the authorized user. DOMAIN.COM can also be an IP address; for example, when setting up a server on a local network.
Sourcehut repositories have URLs like:
git@git.sr.ht:~USERNAME/REPOSITORY_NAME
In git, create a new remote:
git remote add SHORT_NAME URL
Create a new repository, add files to it, etc and run git init. Then, push it to the remote:
git push SHORT_NAME BRANCH_NAME
Don’t forget to set to track the remote branch:
git branch --set-upstream-to=origin/main main
Full example:
eval ""
ssh-add ~/.ssh/keyname
mkdir sonya
cd sonya
echo "Diabetes simulator">README.md
git init
git add --all
git commit -m "initial commit"
git remote add origin git@git.sr.ht:~freestatelabs/sonya
git push origin main
git branch --set-upstream-to=origin/main main
Result:
Initialized empty Git repository in ~/sonya/.git/
[main (root-commit) 63caa53] initial commit
1 file changed, 1 insertion(+)
create mode 100644 README.md
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 229 bytes | 229.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
remote:
remote: NOTICE
remote:
remote: You have pushed to a repository which did not exist. ~freestatelabs/sonya
remote: has been created automatically. You can re-configure or delete this
remote: repository at the following URL:
remote:
remote: https://git.sr.ht/~freestatelabs/sonya/settings/info
remote:
remote: Default branch updated to main
To git.sr.ht:~freestatelabs/sonya
* [new branch] main -> main
branch 'main' set up to track 'origin/main'.
Git does warn you of this and tell you how to fix it.
You’ve made a new branch and want to send it to the remote host.
git push --set-upstream origin BRANCH_NAME
From the project root where the dependency should be added:
git submodule add DEPENDENCY_URL DEPENDENCY_PATH
For example:
git submodule add https://git.sr.ht/~freestatelabs/shepherd vendor/shepherd
Note that there are special processes for handling git submodules; it sounds like they work best when the dependency is updated infrequently. See Git docs and Atlassian docs.
git config user.name "FIRST LAST"
git config user.email "EMAIL@DOMAIN.COM"
cat .git/config # to check