From a4c48485243ab9c61327663c7898aafa7d05821d Mon Sep 17 00:00:00 2001 From: root Date: Thu, 28 May 2026 02:55:06 +0300 Subject: [PATCH] update git.sh --- git.sh | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/git.sh b/git.sh index 4d075cc..4132c90 100644 --- a/git.sh +++ b/git.sh @@ -1,14 +1,29 @@ +#!/bin/bash + echo "name for commit: " read com git add . git commit -m "$com" -git remote add gitflic git@gitflic.ru:hhu67/proj.git -git remote add github git@github.com:hhu67/my.git -git remote add gitea git@gitek.duckdns.org:hhu67/my.git -git remote add berg ssh://git@codeberg.org/hhu67/my.git -git remote add gitea.org git@gitea.com:hhu67/my.git -git push gitflic main -git push github main -git push gitea main -git push berg main -git push gitea.org main \ No newline at end of file +declare -A remotes=( + ["gitflic"]="git@gitflic.ru:hhu67/proj.git" + ["github"]="git@github.com:hhu67/my.git" + ["gitea"]="git@gitek.duckdns.org:hhu67/my.git" + ["berg"]="ssh://git@codeberg.org/hhu67/my.git" + ["gitea.org"]="git@gitea.com:hhu67/my.git" +) +manage_remote() { + local name=$1 + local url=$2 + + if git remote | grep -q "^${name}$"; then + echo "Remote '$name' уже существует, пропускаю добавление." + else + echo "Добавляю remote: $name" + git remote add "$name" "$url" + fi +} +for name in "${!remotes[@]}"; do + manage_remote "$name" "${remotes[$name]}" + echo "Пушу в $name..." + git push "$name" main +done