- Open the terminal window where you can issue git commands from the
command-line.
- 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"
- Make sure you have the most recent versions of the base and hosted repositories:
git pull origin master
git pull mine master
- 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.
- 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
- 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.
- Continuing editing your Java source file 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.
- 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!
- Summary of git commands we use when we are ready to commit:
- 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)
- git push mine master (to upload the most recent version to your BitBucket account)
- 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.
- 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.