Last active
December 9, 2015 23:38
-
-
Save BenConstable/4345316 to your computer and use it in GitHub Desktop.
After a Pull Request of yours is merged, you will want to make sure that your master branch has the changes, and that the feature branch you were working on gets properly tidied up. This simple Git extension does just that.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# This script deletes a feature branch you've been | |
# working on, assuming that it's been merged as part | |
# of a Pull Request, and pulls it into your master | |
# branch. | |
# | |
# You need a typical setup, and a reference to the | |
# forked repo, called `upstream`. | |
# | |
# You can then just run: | |
# | |
# `git merge-feature <branchname>` | |
# | |
# which will: | |
# | |
# - Pull the changes into master | |
# - Push master backup to Github | |
# - Delete remote feature branch | |
# - Delete the local feature branch | |
# | |
# Easy! | |
# | |
# If you want to merge on a branch other than master, | |
# just provide the branch name as the second arguement | |
# to the script. | |
# | |
# To install, put this file somewhere in your path | |
# (I like mine in `~/bin/`). | |
# | |
if [ -z "$2" ]; then | |
branch="master" | |
else | |
branch=$2 | |
fi | |
git checkout $branch | |
git pull upstream $branch | |
git push origin $branch | |
git push origin --delete $1 | |
git branch -D $1 | |
git fetch upstream |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment