Read and follow the instructions in the first three sections of
Using git for
Homework. The sections you
should work through are titled: ``Background'', ``Setting up Your Workspace'',
and ``Setting Up a Hosted Repository''. The URL for the base homework repository
for this course is:
For this lab day you will be required to do work on the computers in the lab so take
time to log in on the day before the lab begins to make sure you remember your
credentials because we will not have time in class to troubleshoot login issues.
To summarize, when you come to class for lab day you should:
- have completed the steps in the first three sections of the document
- have verified you are able to log in to the computers in JB 202
- remember your bitbucket.org credentials
- have established a cloned copy of the base homework repository in your
- When you arrive to class, log in to one of the lab computers. All remaining
steps should be done from a lab computer.
- Open a terminal window and create a clone of your homework repository:
git clone https://firstname.lastname@example.org/yourbitbucketusername/p2_homework.git
- Change directory to the newly created
- In order to remain consistent in our naming, let's go ahead and rename this remote to ``mine''
git remote rename origin mine
git remote -v to verify the rename worked.
- Change directory to the
- Edit the file ParallelArrayMovies.java (you can use gedit or
jgrasp or vim). 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.
- Switch to the data directory (
cd ../data) and then make a copy
of the data file (movielist.txt) and name it
cp movielist.txt tinymovielist.txt
- Edit the new tinymovielist.txt file (you can use gedit or jgrasp
or vim) so that most of the movies are deleted leaving only about 10
movies. Save the file.
- Switch back to the hw01 directory (
cd ../hw01) and edit
the Java source code again and modify the String constant named
DATAFILE so it refers to the new tinymovielist.txt file.
- 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.
- 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.
- 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"
- 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.
- Edit the Java source code and add a new method called searchByYear that
accepts the three arrays as parameters along with the number of elements in the
arrays. It will not return any values. Leave the body of the method blank except
for a single print statement that gives a message ``Search by Year''. Do,
however create a comment that conforms to JavaDoc requirements. As part of your
homework assignment you will actually complete this method. For documentation
purposes you need to know what this function will do: prompt the user to enter
a year and display all movies that match the given year.
NOTE: A method that has a defined header but that does nothing is called a
- If you look at the method called menuChoice you can see that the user
is prompted to enter a value of 6 to select the ``Search By Year'' action. In
main() (inside the while loop) add an if-statement that will call the
mostly empty searchByYear method in the event the user entered a at
the menu. Compile, test, and tweak as necessary to get the changes you made
to work. When the user enters 6 at the menu they should see the output of the
single print statement in the new searchByYear method.
- It is time to commit your changes. Remember the sequence:
- git status (to see what has changed)
- git add xxxx (as necessary to stage changed/new files to be committed)
- git status (to verify everything you want to commit is in the staging area)
- git commit -m "Explanatory Message" (to commit the changes)
- git status (to verify everything committed as you expected)
- 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!
- 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.
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.