- Ajout command git

This commit is contained in:
Frogg 2026-05-09 16:29:39 +02:00
parent b30f13f4a0
commit 4f3785ab16
2 changed files with 28 additions and 6 deletions

View File

@ -1,10 +1,19 @@
get-branch(){
local branch
# Récupère le nom de la branche actuelle
branch=$(git branch --show-current 2>/dev/null)
if [[ -z "$branch" ]]; then
echo "Pas dans un dépôt Git"
exit
fi
echo $branch
}
git-reset(){
local branch
# Récupère le nom de la branche actuelle
branch=$(git branch --show-current 2>/dev/null)
[[ -z "$branch" ]] && echo "Pas dans un dépôt Git" && return 1
branch=get-branch
git fetch origin
git reset --hard origin/"${1:$branch}"
@ -13,6 +22,14 @@ git-reset(){
echo -e "${COLOR_GREEN}✅ Dépôt synchronisé et nettoyé.${NONE}"
}
git-sync(){
local branch
branch=get-branch
git fetch
git pull origin "${1:$branch}"
}
git-clone(){
[[ -z "$1" ]] && echo "Veuillez préciser l'adresse d'un dépôt Git" && return 1
@ -29,6 +46,9 @@ git-clone(){
}
git-set-url(){
local branch
branch=get-branch
git remote set-url origin "$1"
}

View File

@ -56,8 +56,10 @@ if [[ -z "${WELCOME_SCRIPT_PATH}" ]]; then
fi
. "${WELCOME_SCRIPT_PATH}/func/git.sh"
# get last changes
alias gitsync='git-sync'
# restore as depot
alias gitsync='git-reset'
alias gitreset='git-reset'
# classical git clone depot
alias gitclone='git-clone'
# change depot url