Please read free5gc wiki installation carefully.
(Installation · free5gc/free5gc Wiki · GitHub)
And you will find how to get the latest code:
(Alternatively) to install the latest nightly build:
cd ~/free5gc
git checkout main
git submodule sync
git submodule update --init --jobs `nproc`
git submodule foreach git checkout main
git submodule foreach git pull --jobs `nproc`