Skip to content

Instantly share code, notes, and snippets.

@hausdorff
Created April 10, 2014 05:24
Show Gist options
  • Save hausdorff/10344868 to your computer and use it in GitHub Desktop.
Save hausdorff/10344868 to your computer and use it in GitHub Desktop.
# Problem Statement:
# You have mulitple copies (or clones) of upstream repositories in your local drive.
# Your local cloned repos need to be updated against the upstream master repos on a regular basis.
# Here's one solution that uses the IPython notebook.
# Open up your IPython notebook browser in your working directory and then paste the following into a code cell.
# Press SHIFT+ENTER to run the code cell.
# Create a list of projects located in the working directory.
list_of_projects = ["django", "ipython", "oh-mainline"]
def update_and_push_to_origin(folder):
%cd {folder}
!git checkout master
!git fetch upstream
!git stash #Stash any un-committed changes before you rebase against upstream master.
!git rebase upstream/master
print "Updating your origin master branch on Github."
!git push origin master
# Iterate through each project in the array and update each project.
for project in list_of_projects:
print "\nCurrently updating the {!s} project.".format(project)
print "-------------------------------------------------------------\n"
update_and_push_to_origin(project)
%cd ..
# Reference: Adapted from IPython core developer Damian Avilla's blog post: http://www.damian.oquanta.info/posts/dont-write-scripts-just-write-ipyscripts.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment