CSCI 352: Software Engineering
Fall 2017




Many thanks to Dr. Guerin for sharing this with us

Software Engineering Toolkit 4.0: Basic Version Control with git.

Assigned: 9/5
Due: 9/7 before the start of class
NOTE: Screencaps of individual steps will get bonus points if I use them in the next iteration of this course!! Make sure to label your screencaps and tell me where they would be useful!

Libraries You May Use

Description

We will be hijacking one of Dr. Guerin's CS325 assignments to practice working with git. This is meant to be a classwork activity, and will be due before the next class period (in case you don't get all the way through it by the end of the class period). Once you have completed this tutorial, I will provide you with the information needed to get to the class private repository. Note: do not place your paint projects in a public repository.

In practice, a version control system (VCS) is typically the preferred route for the world of software engineering/computer science. Version control software packages are used to track and manage changes to documents, programs, web pages, and just about any other (typically text based) systems that are under active development. The git software package was also developed by Linus Torvalds (of Linux fame), and among other things (e.g., the primary purpose was for Linux kernel development) has become a relatively popular version control system in the real world of software engineering. (Other options exist, however for the purposes of this course we will be focusing on just the one package.)

Advantages of using version control include:

Getting signed up with github.

  1. First, go to github.com and sign up for an account using your university email address. (Very likely you have all done this already)
  2. NOTE: Make sure your GitHub account is linked to your university email, and it is publicly searchable. Furthermore, make sure that your username is linked to your real name or university email handle - Prospective employers will see this!
  3. After you have signed up for your github account, go to your profile (in the upper-right corner of the webpage there should be a dropdown with your github identicon. You will have the ability to upload your own image, but unless you feel like it github will generate a 5x5 "pixel sprite" automatically from your user id. Mine looks like . At any time you should always be able to navigate back to your profile in this way.
  4. In your profile, select the tab. A repository (or repo is essentially a VCS database where all of your project information is stored remotely.
  5. At the start this tab should read that you don't currently have any public repositories. Click the icon to create a new repo.
  6. On the new repository page use the following information to initialize your repository:
  7. Click to create your online repository.
  8. You may want to save the resulting page for a moment (print, screencap, etc.) so you can refer back to it. If you lose track it will not be a big deal, however I often use the links and commands they provide so that I can quickly copy-paste when I create a new repo.
  9. Next, we will be creating a project locally and linking it to your repo.

Creating your project.

This will work a bit differently than how it did on the Linux machines in 325.

  1. First, you will need to have VisualStudio create a new local git repo NOTE: it is not the end of the world if you miss this, it's just going to be a bit tricksier.
  2. Now you have a local repository, we will need to connect it to your remote repository (on github.com)
  3. After VisualStudio finishes publishing, you should be able to refresh your repository window, and see your solution!

Writing/pushing code.

  1. At this point, you should have an empty console project. Modify it to a simple "Hello World!" application.
  2. After ensuring that your code runs correctly, make sure to push it to your remote repository.
  3. Switch to the Synchronize view in the TeamExplorer window, and push your work to your remote repository.
  4. Use the online repository browser to ensure that your Hello World has successfully been synched.

Tracking your progress: Diffs and commits.

  1. Modify your program to become a simple number guessing guessing game
  2. Build and run your code to ensure that it actually works
  3. DON'T COMMIT OR PUSH CHANGES YET!!!
  4. Go to the TeamExplorer window and select Changes, you should see that Program.cs was modified. Double-click on it!
  5. This opens up VisualStudio's Diff. You should see your current code on the right, with what is stored in the remote repo on the left
  6. Create a commit message and commit your code to the local repository.
  7. Switch to the Synchronize view, and push to the remote repository

Creating and merging branches.

  1. Have you ever found yourself creating multiple files (main.cpp, main.old.cpp) to save your old work in case you introduce new (and problematic) errors while you are trying to add a new feature or fix a bug? (I've found myself having to resort to this in a pinch.)
  2. By default your project has a single "branch" called master (as in origin master. You can create an arbitrary number of "branches" from any point in your commit chain in order to add a new feature.
  3. Create a new branch by clicking the icon, and type feature in the box. Normally you would create a more descriptive name for the feature you were working on. At this point you can use the drop-down to view both branches, however the files and their contents should be identical.
  4. In VisualStudio, switch to the Branches view of the TeamExplorer window. Look for your new branch under the remote repositories section.
  5. Add a new feature to your Program.cs: allow the user to selecting a starting number (x) and a stopping number (y). Your program should now start by prompting the user for these 2 numbers, then using them as bounds for your number-guessing game (I am thinking of a number from x to y...)
  6. Commit and push. Check that your modifications made it into your new branch (and only your new branch) through the online repository browser.
  7. Now that we have implemented the feature to our liking we merge the changes back into our master branch. We are going to do this through VisualStudio.
  8. Go back to the Branches view in TeamExplorer, and right-click on your local copy of master. Select Checkout... Double-check that this has reverted you back to your original Program.cs
  9. In the Branches view in TeamExplorer, select Merge at the upper right. You will tell it to merge from Feature into master.
  10. After doing this, make sure to commit all changes, and push them to your remote repository.
  11. Congratulations! You are now ready to start using version control like a professional! We will be starting with a version controlled (through git) version of your next programming assignment.

Adding a collaborator.

  1. For this assignment you will not submit using email, you will simply add me to the project.
  2. On your project page click then . In the search box, you can find me by email (kericson@utm.edu). Click to "Add collaborator", and you are done.
  3. In a real-world project you may have a number of collaborators, including your partner for this course.

What you must turn in.

Nothing. Once you have added me as a collaborator I will be able to view your project, your commit history, and anything else that I need.



Note: Your program must compile and run on a G1 lab machine or it will not be graded. Please see the syllabus for details.