-r specifies the reference to the commit to be synchronized. It can be a tag or a branch. By default, it is
the last commit of branch main.
It can be different from the actual branch. CAREFUL, the command git branch will always show the original branch name even though a branch switch has happened.
-d specifies the destination of the clone or update. Directory must be empty if a new clone is to be made.
If the repository to be cloned is local, and its path is passed as a relative path, the path should start from the destination.
To avoid mistakes, absolute paths are advised.
-H allows the $HOME directory to be used by git_update.sh. By default, git_update.sh cannot access $HOME to
prevent default behavior.
If you need the global .gitconfig located in your $HOME to be used, you should supply the -H option.
-a specifies that the aggressive option of the git garbage collection must be used. Only advised when
changes happen in many different objects. Will slow down the execution.
DESCRIPTION
This script will replace the destination with the wanted commit of a git repository. The history is not preserved but tags are. Untracked files remain.
The git commands have been chosen so as to minimize the memory and bandwidth usages.
Only the commit and the necessary objects will be cloned. The commit can be indicated through a reference, either a tag or branch, otherwise the last commit of main is the default.
git_update.sh will update if the repository already contains a .git. Untracked files and directories will be kept. Any local modification to a tracked file or created tracked file will be deleted in favor of the new commit. The history will only contain the very last commit.
**Result:** a directory myDirectory has been created in the current working directory. It is filled with the files of the last commit of branch myBranch as well as the .git. The history only shows the last commit.
**B) Updating the current working directory repository, moving it from its current state to a certain tag, calling for an aggressive garbage collection.**
git_update.sh has been written by the French association [Jean-Cloud](https://www.jean-cloud.net), in the process of developing Shlagernetes, an orchestration tool.
You can find them under [/test/performance_tests](./test/performance_tests).
Please refer to [/doc/development_explanations](./doc/development_explanations) for more information about the tests and choices made in the elaboration of git_update.sh.
Please refer to the readme of test [/test/README.md](./test/README.md) and the readme of functional_tests [/test/functional_tests/README.md](./test/functional_tests/README.md).