- Ajout command git
This commit is contained in:
parent
b30f13f4a0
commit
4f3785ab16
30
func/git.sh
30
func/git.sh
|
|
@ -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"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue