Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Linux shell script to automate the setup tasks for doing work on public Github Python projects
#!/bin/bash -i
# Note: Script must run in interactive mode (/bin/bash -i) in shebang line
# Description:
# Automatically fork an open source Github Python project and setup a local
# virtual environment to work on it inside a new branch.
# This is especially useful for quickly submitting a patch to a project, and
# is just a wrapper script tying together a few existing great utilities.
# Usage:
# $ github_fork <repo_username> <repo_name> <new_branch_name>
# Example:
# To fix a bug in, say, the mezzanine project:
# $ github_fork stephenmcd mezzanine mybugfix
# Now it's forked, and you're ready start working in the new local branch
# "mybugfix", which has been created in a virtual env.
# Requirements:
# - a Github account
# - git
# - hub (
# - virtualenvwrapper (
# Enable virtualenvwrapper commands
source /usr/local/bin/
alias git=hub
echo "----> Cloning $REPO_NAME"
echo "----> Creating virtual environment"
mkvirtualenv $REPO_NAME
echo "----> Creating new local branch $FEATURE_NAME"
git checkout -b $FEATURE_NAME
echo "----> Forking $REPO_NAME on GitHub"
git fork
echo "======================================================================="
echo "When finishing and commiting the repo changes, type:"
echo "$ git push <your_github_username> $FEATURE_NAME"
echo "Then..."
echo "$ git pull-request"
echo "...a text editor will open to enter the pull request's title & message"
echo "======================================================================="
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment