Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Beginning to use Git for FreeBSD ports: a rough guide

Beginning to use Git for FreeBSD ports: a rough guide

Not for committers.

Please treat this page as work in progress during the transition to Git.


  1. rm /var/db/gitup/ports
  2. rm -r /usr/ports/*
  3. rm -r /usr/ports/.git*
  4. rm /usr/ports/.arcconfig
  5. rm /usr/ports/.portsnap.INDEX
  6. ls -adhl /usr/ports/.*
  7. remove anything else that no longer has a place.


  • if the /usr/ports/ directory exists, it must be empty.

If you use FreeBSD 13.⋯, or OpenZFS with FreeBSD 12.⋯

There's the option of zstd-19 for aggressive compression of future writes to your filesystem. Do this only if your computer is suitably specified. Example:

zfs set compression=zstd-19 copperbowl/usr/ports

The initial clone

git -C /usr clone -o freebsd -b main ports

Routine updates

git -C /usr/ports pull --ff-only

– or if you also work with FreeBSD documentation and source files:

git -C /usr/doc pull --ff-only && git -C /usr/ports pull --ff-only && git -C /usr/src pull --ff-only

Copy link

paulfloyd commented Apr 10, 2021

I think that /usr/ports must be empty, otherwise you will get
fatal: destination path 'ports' already exists and is not an empty directory.

Rather than always specifying --ff-only, if you run git pull without this you will get a load or orange text that explains the command to set the default pull option. If you only build in the ports directory then fast forward is a good choice. If you modify things then merge is probably a better choice.

Copy link

grahamperrin commented Apr 10, 2021


I think that /usr/ports must be empty, … – now an essential point.

I could simplify the preparations i.e.

  1. rm -r /usr/ports/
  2. you'll see Device busy if /usr/ports/ is a ZFS filesystem, which can not be removed in this way.

– although I quite like the longer steps, for beginners to get a rough idea of the types of hidden file that can be present.

… If you modify things …


Not for committers.

Is --ff-only sane for all non-commit use cases?

Copy link

paulfloyd commented Apr 11, 2021

All of the options are reasonable. but I would recommend --ff-onlyfor people that just want to build ports. If you are modifying files then --rebase=false is what I'd recommend.

Without such options git will suggest

hint:   git config pull.rebase false  # merge (the default strategy)
hint:   git config pull.rebase true   # rebase
hint:   git config pull.ff only       # fast-forward only

I use the 1st of those 3 options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment