Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
31 lines (30 sloc) 760 Bytes
#!/bin/bash
set -e
destination='master'
branch=$(git rev-parse --abbrev-ref HEAD)
git checkout ${destination}
git pull
git checkout ${branch}
git checkout -b ${branch}-backup
git checkout ${destination}
git branch -D ${branch}
git checkout -b ${branch}
git merge --squash ${branch}-backup
_done="
Everything seems fine. Next steps:
git status
git commit # Or re-stage and do multiple commits
git push --force-with-lease --set-upstream origin ${branch}
To undo:
git reset HEAD .
git checkout -- .
git checkout ${destination}
git branch -d ${branch}
# If branch exists on GiHub:
git branch -D ${branch}-backup
git fetch
git checkout ${branch}
# Else:
git branch -m ${branch}-backup ${branch}
"
echo "$_done"
You can’t perform that action at this time.