Travail sur le fichier git_update.sh et un fichier de tests associé
Go to file
2024-07-24 13:57:26 +02:00
doc test directory complete 2024-07-24 13:57:26 +02:00
src initialization 2024-07-23 21:34:37 +02:00
test test directory complete 2024-07-24 13:57:26 +02:00
.gitignore avec un .gitignore 2024-06-25 15:57:35 +02:00
readme initialization 2024-07-23 21:34:37 +02:00


# Overview
git_update.sh is a  bash script performing a punctual synchronization of a git repository. 
The script will replace the indicated destination with the wanted commit of a git repository. The history is not preserved but tags are.
The git commands have been chosen so as to minimize the memory and bandwidth usages."

# Download
Download the git_update.sh file.
Git has to be installed on your computer. 
# Use
Extract of the help:
NAME
    git_update.sh
SYNOPSIS
    git_update.sh [-h] [-r ref] [-d dest] [-H] [-N] [-a] repository
OPTIONS
	-h prints the help. 
	-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 
./path/to/git_update.sh -r myBranch -d myDirectory https://git.mydomain/myname/myrepository.git 
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.
./path/to/git_update.sh -r myTag -d myDirectory -N https://git.mydomain/myname/myrepository.git 
Result: all the files of myDirectory have been kept, except those whose names were identical with files of myTag. Files of myTag have been imported

# Development process
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.