LD01: Using git for Homework due Fri 19 Jan 10:00

\begin{purpose}
In this assignment you will:
\begin{itemize}
\item Establish...
...s for working with {\tt git} from the command-line
\end{itemize}
\end{purpose}

Preparation for Lab Day

NOTE: This prelab assignment is more time-consuming than most. Complete the following steps before coming to lab day:
  1. If you haven't done so already create an account at https://bitbucket.org using your hsutx.edu email address. If you have an account but it is associated with a different address you can either create a separate account or add your HSU address as an alias (see settings) to the existing account.

  2. Create a repository by importing from the course repository:
    • Log in to your bitbucket.org account.
    • In the menu at the top choose: Repositories->Import repository.
    • The repository you are importing from is:

      https://bitbucket.org/tsergeant/p2_homework.git

    • Keep the name p2_homework
    • Make sure the new repository is marked as private.

    NOTE: By doing this operation you are making a copy of the base course repository in your own bitbucket.org account. This copy will be where you post all of your work this semester.

    NOTE: When the import operation completes you should be at the overview page of the newly created repository.

  3. Share the newly imported repository with your instructor. This is probably found at Settings -> General -> User and Group Access. IMPORTANT: Under "Users" specify this email address for sharing: terrys@gmail.com

  4. Read the commentary and watch this video to get a sense of the big picture of how we are going to set things up: https://hsutx.instructure.com/courses/13381/modules/items/436336

    NOTE: Up to this point we have completed setting up the top part of the diagram: base repository (aka origin) and your hosted repository (aka mine). The remaining steps will complete the bottom part of the diagram in which you will set up a workspace on your local computer where you will actually do your work.

  5. Install git on your local computer by following these instructions: https://hsutx.instructure.com/courses/13381/modules/items/436337

  6. We will be issuing git commands from a command-line interface this semester. To learn how to get around on a command line read/watch these lessons:

  7. Now you are ready to create a workspace on your local computer. You will need to open a terminal on your computer (use Git Bash in Windows) and then issue the “Setup Commands” found here: https://hsutx.instructure.com/courses/13381/modules/items/436338

    NOTE: Also, watch the video at the link above.

Lab Day

For lab day you will need your own laptop computer and it will need to have a workspace already setup on it in accordance with the prelab instructions above.

  1. Open the terminal window where you can issue git commands from the command-line.

  2. Verify that you have no uncommitted changes: git status (should indicate that everything is up-to-date). If not then you'll need to commit the changes as follows:
    git add .
    git status
    git commit -m "meaningful message explaining what changes you are committing"
    

  3. Make sure you have the most recent versions of the base and hosted repositories:
    git pull origin master
    git pull mine master
    

  4. Edit the file ParallelArrayMovies.java that is found in the hw01 directory (you can use jgrasp or whatever other editor you normally use when writing Java programs). In the comment block at the top enter your name as author and the current date as version. Then compile and run the program as it is. Enter a new movie and then list all movies to verify it was entered correctly.

  5. Use the command-line to do this step. Switch to the data directory of your repository: (cd p2_homework/data) and then make a copy of the data file (movielist.txt) and name it tinymovielist.txt:

    cp movielist.txt tinymovielist.txt

  6. Edit the new tinymovielist.txt file (use any available text editor) so that most of the movies are deleted leaving only about 10 movies. Save the file.

  7. Continuing editing your Java source file and modify the String constant named DATAFILE so it refers to the new tinymovielist.txt file.

  8. Back at the command line enter the command: git status

    Take time to observe the output. This command will be used often to determine what has changed since the last commit. In this case it should indicate that you have modified a file and created a new file and that both of those actions are “unstaged” ... which means you haven't indicated that you want these changes to be remembered.

  9. We need to tell git that we want our changed to be included in the next commit so you will add them to your staging area with these commands: git add ParallelArrayMovies.java and git add ../data/tinymovielist.txt. Now issue the git status command again and compare the output with the previous result. It should show these changes as having been staged.

  10. Now we are ready to commit. With each commit you will attach a message indicating the changes you are committing. Use this command:

    git commit -m "Created Small Datafile for Testing Purposes"

  11. Issue git status again and verify that there are no uncommitted changes. If you use git log you should see there are now two commits.

  12. We are done making changes to this source code for lab day so let's go ahead and push our most recent changes to BitBucket: git push mine

    When you are prompted to enter a password you will enter your BitBucket password. If successful, your BitBucket repository will reflect all of the changes you just made. So, when you are ready to work on your homework you will begin by pulling the changes from BitBucket into whatever environment you plan to use for working on homework. NOTE: MAKE SURE YOU FINISH THIS STEP!

  13. Summary of git commands we use when we are ready to commit:
    1. git status (to see what has changed)
    2. git add xxxx (as necessary to stage changed/new files to be committed)
    3. git status (to verify everything you want to commit is in the staging area)
    4. git commit -m "Explanatory Message" (to commit the changes)
    5. git status (to verify everything committed as you expected)
    6. git push mine master (to upload the most recent version to your BitBucket account)

  14. Postscript: This lab day is quite a bit different than most will be. In particular the instructions were especially prescriptive. In the future the instructions will not include specific commands to type. The purpose of this lab day was to walk you through the process of working with a VCS. Feel free to refer back to these steps if you don't remember a specific git command.

  15. If you finish early, take time to begin reading the homework assignment. For that assignment you will be need to do your work in whatever environment you set up in the prelab for doing homework.