My Git for CS137 setup


I’ve been using Git and GitHub for all of my CS137 assignments, in part to keep the files in sync between my desktop and laptop, as well as the UW server that I use for testing. The keeping everything in source control is a bonus, but one that comes in handy, especially branching when I discover that actually my code can be rewritten in a better way.

The primary impetus for this post is that I’ve been creating a branch for each assignment, but I still have yet to get the branching push/pull commands down pat, so I always end up searching Google for the appropriate commands. After 6 branches (and counting), I’ve gotten tired of that, so I shall centralise it in one place:

Pushing a new branch: git push origin new_branch

Pulling a new branch: or git pull && git checkout --track origin/new_branch or git checkout new_branch

Getting stuff set up:

First of all, get a GitHub educational account that’ll allow you to have private repos – no accusations of plagiarism here, thankyouverymuch.

Second, get Git installed & set up (More detail in my python dev environment post): Download Git from git-scm.com/downloads, and installed it following GitHub’s Windows setup guide.

Third thing is to follow Github’s guide on generating ssh keys, if you want password-less pushing. (Which requires the use of Git Bash.)

Repeat for desktop/laptop/server.

Using it:

Laptop/desktop: Git GUI can be used for just about everything. I only use Git Bash for the pushing to/pulling from GitHub, and that’s because I use ssh-agent to keep pushes quick. Before I start editing I do a pull from GitHub just to make sure I’m in sync, so I don’t get problems

Server: Exclusively use it for pulling from GitHub. Editing can be done there, but that’s an additional complication re pushing it back. Also, notepad++ is a nicer GUI than vim + PuTTY.

And a few random things I’ve noticed:

  • PuTTY has encoding problems periodically, particularly on Ubuntu machines . Fix to this is to force UTF8 encoding in Settings > Translation. Ubuntu (and possibly Debian machines) are seemingly susceptible to this than Fedora. Not sure why, but it would likely have to do with the default terminal encoding.
  • Using ssh-agent was a pain until I figured out the command to get it to run properly – On my desktop/laptop, it’s a quick eval `ssh-agent` and ssh-add, and on the UW server, I just have a screen session open with ssh-agent running in it.
  • (This is UW server specific) Screen sessions doesn’t transfer between servers. UW has a load balancer that’ll redirect your SSH connect to one of three servers transparently. I believe this is on the DNS level rather than an actual load balancer (haven’t used dig to look into that yet), but connecting to linux.student.cs.uwaterloo.ca would seemingly randomly make my screen session disappear, only for it to reappear later. Solution was to hard code the server as linux032.student… in the putty host field.

, ,

  1. No comments yet.
(will not be published)