Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.0 kB
3
Indexable
Never
#!/bin/sh
if [ "$#" -ne 1 ]; then
  echo "Usage: $0 COMMIT_MSG" >&2
  exit 1
fi


COMMIT_MSG="$1"
CURRENT_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
TEMP_BRANCH="temp_${CURRENT_BRANCH}"

echo "Current: ${CURRENT_BRANCH}"
echo "Temp: ${TEMP_BRANCH}"

echo ""
echo "1. Pull current branch"
git pull | exit 1

echo ""
echo "2. Checkout develop"
git checkout develop | exit 1

echo ""
echo "3. Pull develop branch"
git pull | exit 1

echo ""
echo "4. Create temp branch"
git branch "${TEMP_BRANCH}" | exit 1

echo ""
echo "5. Checkout temp branch"
git checkout "${TEMP_BRANCH}" | exit 1

echo ""
echo "6. Merge current branch in temp branch"
git merge --squash ${CURRENT_BRANCH} | exit 1

echo ""
echo "7. Git commit"
git commit -m "${COMMIT_MSG}" | exit 1

echo ""
echo "8. Checkout current branch"
git checkout "${CURRENT_BRANCH}" | exit 1

echo ""
echo "9. Reset current branch from temp"
git reset --hard "${TEMP_BRANCH}" | exit 1

echo ""
echo "10. Delete temp branch"
git branch -D "${TEMP_BRANCH}" | exit 1