very conservative ports git primer for someone like me who does not know git and is afraid of making any mistake

  1. do something about your current /usr/ports, or adjust the last argument in the following command to your liking.

  2. clone the repo; notice that it's via https (read-only), we'd only be pulling from it:
    git clone -o freebsd -b main --depth=1 https://git.freebsd.org/ports.git /usr/ports
    shallow clone is to cope with poor/unstable network connection, as git does not support resumable clone/fetch — i get my internet via punched cards, if yours is better, you can omit this option

  3. make sure you have your username and email correctly set:
    git config user.name "Jane Doe"
    git config user.email jane@FreeBSD.org
  4. configure the push URL for the upstream repository:
    git remote set-url --push freebsd ssh://git@gitrepo.freebsd.org/ports.git
    yes, "ssh://git@..." is really correct here; "git@gitrepo.freebsd.org:ports.git" should also work

  5. prepare your work and commit (locally) only things you want:
    git commit -m 'commit message' dir1 dir2 file1 file2 ...
    or
    git commit -F /tmp/commit-log.txt dir1 dir2 file1 file2 ...
  6. check with git show HEAD that everything is in order, commit message is okay (e.g. there is no untrimmed template leftovers), no bogus files had been accidentally included, review the diff again, etc. if found something, amend the commit.

  7. assuming that commit hash that was generated for you is $sha1, push the commit to FreeBSD central repo (main branch):
    git push freebsd $sha1:main
  8. that's all! you can repull now and should see your commit together with others' that might have happened in the meantime:
    git pull
  9. if something went wrong, and git fires your $EDITOR and asks you to ...wtf... merge or whatever, this should help:
    pkill -1 git; git merge --abort; git pull --ff-only --rebase freebsd main