Skip to content

Instantly share code, notes, and snippets.

@sampart
Created September 27, 2013 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sampart/6729508 to your computer and use it in GitHub Desktop.
Save sampart/6729508 to your computer and use it in GitHub Desktop.
PR been merged on github? This will checkout develop, git pull so that develop has the merged changes, and then delete the branch you were on.
#!/bin/bash
# PR been merged on github? This will checkout develop, git pull, and then delete the branch you were on.
# Thanks http://stackoverflow.com/a/1593487/328817
branch_name="$(git symbolic-ref HEAD 2>/dev/null)" ||
branch_name="(unnamed branch)" # detached HEAD
branch_name=${branch_name##refs/heads/}
if [ "$branch_name" = "develop" ] || [ "$branch_name" = "master" ]
then
echo "Only for feature branches!"
exit 1;
fi
git checkout develop
git pull origin develop
git branch -d $branch_name
git branch # I like to know what branches I've got left
@sampart
Copy link
Author

sampart commented Apr 19, 2018

It's worth noting that this fork is better as it allows you to specify a branch in place of develop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment