Advertisement
Guest User

deeznoots

a guest
Dec 10th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. #! /bin/bash
  2.  
  3. # This script will clone an exercise for you, and reset all of
  4. # the upstream tracking to a repository that you own. The end
  5. # result of this is that you will be able to use "origin/master"
  6. # the way you would have had you initially cloned a repository
  7. # in which you have full permissions.
  8.  
  9. # Check to make sure we were invoked correctly.
  10. if [ $# -lt 2 ]
  11. then
  12. echo "Usage: $0 <course number> <exercise>" >&2
  13. exit 1
  14. fi
  15.  
  16. # Save the command-line arguments with friendlier names.
  17. cnum=$1
  18. repo=$2
  19.  
  20. # Get our name on the git server.
  21. json=$(ssh git@gizmonic.cs.umd.edu info -json)
  22. user=$(python -c "print $json['GL_USER']")
  23. echo "We are ${user} on gizmonic"
  24.  
  25. # Remember where we are now.
  26. d=$(pwd)
  27.  
  28. # First, get the official release of the exercise.
  29. git clone git@gizmonic.cs.umd.edu:exercises${cnum}/${repo}
  30.  
  31. # Now we're going to go into the repo and mess with the remote
  32. # tracking.
  33. cd ${repo}
  34.  
  35. # We don't want to lose the original location, so we'll flag it
  36. # as "upstream". This will also help us update things if there
  37. # is an issue that the instructors need to fix.
  38. git remote rename origin upstream
  39.  
  40. # Now we set up the new "origin", which will be in our project
  41. # namespace. We fetch and push to create the actual remote repo.
  42. git remote add origin git@gizmonic.cs.umd.edu:proj${cnum}/${user}/${repo}
  43. git fetch origin
  44. git push origin master
  45.  
  46. # There's now a valid remote at "origin", so let's tell git that
  47. # the master branch should treat this as the default upstream.
  48. git branch --set-upstream-to=origin/master master
  49.  
  50. # Finally, let's go back to where we invoked this script.
  51. cd $d
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement