Skip to content

Instantly share code, notes, and snippets.

@DineshSolanki
Created May 23, 2021 11:26
Show Gist options
  • Save DineshSolanki/b7af4e277e379ab1e67b9a6c6365f783 to your computer and use it in GitHub Desktop.
Save DineshSolanki/b7af4e277e379ab1e67b9a6c6365f783 to your computer and use it in GitHub Desktop.
Backmerge current branch with master/developer or any branch
#!/bin/bash
branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
IFS='/' read -r id bname <<< "$branch"
IFS='_' read -r id bname <<< "$bname"
git update-index -q --refresh
if ! git diff-index --quiet HEAD --; then
echo "Working directory not clean, please commit your changes first"
exit
fi
echo "-------------------------------------------------------------------------"
echo "Switching to develop"
git checkout develop
echo "-------------------------------------------------------------------------"
echo "Pulling develop"
git pull
echo "-------------------------------------------------------------------------"
echo "switching to ${branch}"
git checkout ${branch}
echo "-------------------------------------------------------------------------"
echo "merging develop with ${branch}"
git merge develop
echo "-------------------------------------------------------------------------"
echo "Backmerge done..."
#change develop to whatever branch you want
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment