shell-scripte-code/sgit
simono41 8048acd4eb fix
2020-03-10 10:32:35 +01:00

40 lines
1.1 KiB
Bash
Executable file

#!/bin/bash
set -ex
if [[ "--help" == "${1}" ]]; then
echo "bash ./sgit user.email commit"
fi
if [[ -z "${2}" ]]; then
echo "Bitte email und commit angeben!!!"
exit 1
fi
push="${3}"
[[ -z "${push}" ]] && push="origin"
branch="${4}"
[[ -z "${branch}" ]] && branch="master"
git config --global core.editor "vim"
git config --global user.email "${1}"
git config --global user.name "${1}"
git config --global push.default simple
git config --global credential.helper store
git config --local core.sshCommand "ssh -i $HOME/.ssh/id_rsa"
#git branch --set-upstream-to=origin/master master
git status
git add --all
git commit --all -m "${2}"
git show
if ! GIT_SSH_COMMAND="ssh -oPort=1022" git pull "${push}" "${branch}"; then
echo "Konnte keine neuen Daten vom Server hollen!!!"
fi
if ! GIT_SSH_COMMAND="ssh -oPort=1022" git push --set-upstream "${push}" "${branch}"; then
echo "Konnte keine neuen Daten zum Server pushen!!!"
fi
git status
if ! GIT_SSH_COMMAND="ssh -oPort=1022" git pull "${push}" "${branch}"; then
echo "Konnte keine neuen Daten vom Server hollen!!!"
fi