CS 151

Cover page image

Cay S. Horstmann

Lecture 5

Lecture 5 Clicker Question 1

Lecture 5 Clicker Question 2

Lecture 5 Clicker Question 3

Lab

Compiling/Running from the Command Line

The .gitignore File

  1. Coder: Type git status. Scribe: What files do you see that should not be checked into the repo?
  2. Don't add class files or Eclipse configurations to a repo. Class files can be obtained by recompiling. Eclipse configurations contain icky path names like c:\Program Files\whatever that are meaningless on other systems.
  3. Run git rm --cached file or git rm --cached directory to remove any files that you want to suppress. The --cached means that the files won't be deleted from your local directory.
  4. Now run git status again. What is the difference?
  5. Using your favorite text editor, make a file .gitignore in the ~/cs151 directory. (Note the file name has ten characters, including a period in the front.) Add the following lines:
    **/*.class
    .project
    .classpath
    .settings
    
    (If you use IDEA or NetBeans, add whatever is needed to filter out those configurations.)
  6. Now run git status again. What is the difference?
  7. At this point, both the coder and the scribe should have a clean git status. If not, run git add to add any files that you previously forgot to add. Then run git commit and git push
  8. Both of you should check your BitBucket/Github site to make sure that all files are where they should be.

Directory names

  1. Both coder and scribe: Run
    cd ~/cs151
    ls -a
    
    What happens?
  2. The . and .. directories are the current and parent directory. The .git directory contains files that Git needs. You should see a file hw1scores.txt. Don't mess with any of those. Then you should see seven directories hw1, hw2, lab1, lab2, lab3, lab4, lab5. All in lowercase. No spaces, underscores, dashes, etc. There should be no other directories.
    Is that what you see?
  3. If not, it's time to clean up. Use the command git mv to move a directory, and to tell Git what's happening. (If you just use mv, then Git will cry loudly that the old directory was lost and it doesn't know the new one.) For example,
    git mv "HW 1" hw1
    If there is a file that shouldn't be there at all, run git rm to remove it. This will remove it from your computer as well, so don't do that with files that should be in .gitignore.

Discussion