Следующее не работает со шкафом, но с незафиксированными изменениями в рабочем каталоге. Он создает ветвь, автоматически вводит все текущие изменения и нажимает на пульт:
commit_and_push_ ( ) {
# This will:
# 1. checkout a new branch stash-XXX
# 2. commit the current changes in that branch
# 3. push the branch to the remote
local locbr=${1:-autostash-XXX}
git checkout -b $locbr
git add .
git commit -a -m "Automatically created commit"
git push origin $locbr
echo "Autocommitted changes in branch $locbr ..."
}
Используйте как:
commit_and_push_ my-temp-branch
commit_and_push_