-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.
-d specifies the destination of the clone or update. If it is non-empty and you want to keep the non-conflicting files, -N must be supplied. Otherwise all files will be deleted, even if gitignored.
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.
-N indicates that the destination is non-empty. The files that do not conflict and, if it is an update, are not committed, will be kept.
By default, all files which are not in the imported commit are deleted, included those in the .gitignore.
-a specifies that the aggressive option of git clean must be used. git clean is called when -N is not supplied.
# Examples
A) I want to clone the last commit of a branch into a non-existing directory
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, however the tags are accessible.
B) I want to clone a certain tag into a preexisting directory.
git_update.sh has been written by the French association Jean-Cloud, in the process of developing Shlagernetes, a new orchestration tool. Shlagernetes allows storing services on fallible second-hand servers and tries to consume the less possible resources.
Several tests have been performed in order to find the most energy-saving Git commands. If you want more information on this process, you can consult our development repository. There you will find the tests scripts as well as a development_story text, detailing the different Git command options.
# How to contribute
If you have any suggestion or question about git_update.sh, please contact us at contact@jean-cloud.org. We would be delighted to hear your feedback.