I need to read-only mirror some Git repositories in my local network due to rather slow internet speed. Target would be to update these repositories with crontab just before office hours, so local mirrors would have fresh content at the beginning of the working day.
Currently, I have a local network server, let say name "git.localnetwork", running Ubuntu 22.04. On this, I have directory structure:
/var/www/html/git-mirror/<mirrored git sites>
For example:
/var/www/html/git-mirror/source.codeaurora.org/external/imx/linux-imx.git
On each mirrored repository, I have performed following steps to create the mirror, above given as example:
me@git:/var/www/html/git-mirror$ mkdir -p source.codeaurora.org/external/imx
me@git:<path>$ cd source.codeaurora.org/external/imx
me@git:<path>$ git clone --mirror git git://source.codeaurora.org/external/imx/linux-imx.git
me@git:<path>$ cd linux-imx.git
me@git:<local_mirror_repo_dir>$ git lfs fetch -all
As I understand, these steps are needed in order to create mirror some git repository along with its LFS objects.
Now, to the question: What is the proper way to update these mirrors so, that after command execution, they are again 1:1 snapshot of the remote repository, along with LFS objects? Following have been suggested in various StackOverflow answers, but my understanding of Git is not enough to find out, what of these would be the proper one, and whether they will also update LFS objects.
me@git:<local_mirror_repo_dir>$ git pull
me@git:<local_mirror_repo_dir>$ git fetch
me@git:<local_mirror_repo_dir>$ git fetch --prune
me@git:<local_mirror_repo_dir>$ git remote update
me@git:<local_mirror_repo_dir>$ git remote update --prune
There is no need or reason to push any local changes to remote repository, as these are read-only repositories.