Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/bash
- # This script will clone an exercise for you, and reset all of
- # the upstream tracking to a repository that you own. The end
- # result of this is that you will be able to use "origin/master"
- # the way you would have had you initially cloned a repository
- # in which you have full permissions.
- # Check to make sure we were invoked correctly.
- if [ $# -lt 2 ]
- then
- echo "Usage: $0 <course number> <exercise>" >&2
- exit 1
- fi
- # Save the command-line arguments with friendlier names.
- cnum=$1
- repo=$2
- # Get our name on the git server.
- json=$(ssh git@gizmonic.cs.umd.edu info -json)
- user=$(python -c "print $json['GL_USER']")
- echo "We are ${user} on gizmonic"
- # Remember where we are now.
- d=$(pwd)
- # First, get the official release of the exercise.
- git clone git@gizmonic.cs.umd.edu:exercises${cnum}/${repo}
- # Now we're going to go into the repo and mess with the remote
- # tracking.
- cd ${repo}
- # We don't want to lose the original location, so we'll flag it
- # as "upstream". This will also help us update things if there
- # is an issue that the instructors need to fix.
- git remote rename origin upstream
- # Now we set up the new "origin", which will be in our project
- # namespace. We fetch and push to create the actual remote repo.
- git remote add origin git@gizmonic.cs.umd.edu:proj${cnum}/${user}/${repo}
- git fetch origin
- git push origin master
- # There's now a valid remote at "origin", so let's tell git that
- # the master branch should treat this as the default upstream.
- git branch --set-upstream-to=origin/master master
- # Finally, let's go back to where we invoked this script.
- cd $d
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement