The assignments listed here should take you approximately 55 total minutes.
CAREFULLY READ ALL THE INSTRUCTIONS BEFORE STARTING THESE EXERCISES!
To start this assignment:
- Click the button in the upper right-hand corner that says Fork. This is now your copy of the document.
- Click the Edit button when you're ready to start adding your answers.
- To save your work, click the green button in the bottom right-hand corner. You can always come back and re-edit your gist.
Need help? You can go back to the files/directories portion of the lesson here.
Scroll down to the bottom of this page and look at the image of the directories and files. Use commands in your terminal to create the directories and files structured exactly how they appear in the image.
When you're done, type history
to see your commands. Copy and paste the commands that were used to create the directory and files:
315 mkdir session_3_practice
316 cd session_3_practice
317 mkdir practice
318 mkdir notes
319 cd practice
320 mkdir projects
321 cd projects
322 touch game.js
323 cd ..
324 touch git_practice
325 cd ..
326 touch budget.csv
327 touch mentors.txt
328 cd notes
329 touch git_notes.txt
330 touch command_line_notes.txt
Since this is just a practice directory, feel free to remove the parent directory session_3_practice
when you're done with this exercise.
Follow the steps below to practice the git workflow. Be ready to copy-paste your terminal output as confirmation of your practice.
- Create a directory called
git_homework
. Inside of there, create a file calledquotes.txt
. - Initialize the directory
- Use
git status
to ensure you are set up for tracking using Git - Add your
quotes.txt
file to the staging area - Check the
git status
- Create an initial commit (Note: Be sure to follow the correct message format for your first commit!)
- Check the
git status
- Add your favorite quote to the
quotes.txt
file - Check the
git status
- Check the changes you've made using
git diff
- Add the changes to the staging area
- Commit the new changes (Note: Be sure to follow convention for commit messages!)
- Check the status
- Show the log of your work in
oneline
format usinggit log
(This will likely require some Googling)
Copy and paste all of the terminal text from this process below (not just the history):
Steven@newusers-MBP ~ % mkdir git_homework
Steven@newusers-MBP ~ % cd git_homework
Steven@newusers-MBP git_homework % touch quotes.txt
Steven@newusers-MBP git_homework % git init
Initialized empty Git repository in /Users/Steven/git_homework/.git/
Steven@newusers-MBP git_homework % git add .
Steven@newusers-MBP git_homework % git status
On branch main
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: quotes.txt
Steven@newusers-MBP git_homework % git commit -m "initial commit"
[main (root-commit) f0df790] initial commit
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 quotes.txt
Steven@newusers-MBP git_homework % git status
On branch main
nothing to commit, working tree clean
Steven@newusers-MBP git_homework % atom quotes.txt
Steven@newusers-MBP git_homework % git diff
diff --git a/quotes.txt b/quotes.txt
index e69de29..740d24e 100644
--- a/quotes.txt
+++ b/quotes.txt
@@ -0,0 +1 @@
+"injustice anywhere is a threat to justice everywhere"
Steven@newusers-MBP git_homework % git status
On branch main
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: quotes.txt
no changes added to commit (use "git add" and/or "git commit -a")
Steven@newusers-MBP git_homework % git add .
Steven@newusers-MBP git_homework % git commit -m "add quote"
[main 8f4879f] add quote
1 file changed, 1 insertion(+)
Steven@newusers-MBP git_homework % git status
On branch main
nothing to commit, working tree clean
Steven@newusers-MBP git_homework % git log --oneline
8f4879f (HEAD -> main) add quote
f0df790 initial commit
Steven@newusers-MBP git_homework %
IMPORTANT: Do NOT remove this git_homework
directory. You will be using this directory during the next session.
Look at the template below for a ConvenienceStore
class. Fill in missing blanks with additional attributes and methods.
Class: ConvenienceStore
Attributes:
- totalSales (integer)
- hours (integer)
- address (string)
- storeName (string)
- isOpen (boolean)
- paymentApproval (boolean)
- candyInventory (array)
- employeeName (array) **EXTENSION**
Methods:
- closeStore (updates the isOpen attribute to false)
- updateTotalSales (updates the totalSales attribute with new sales data)
- itemSold (updates the candyInventory attribute with new sale data)
- doorOpen (udpates customerCount attribute with new client data)
- itemRestock (updates the cigaretteInventory attriubte with new on hand data)
-
Make sure that your shell is set to zsh by running the following command:
$ chsh -s /bin/zsh
. Remember to omit the$
! Note that macOS Catalina and later operating systems already use zsh as the default shell. -
Watch this video and follow each step to modify your own
zshrc
configuration file. As mentioned in the video, you will need this snippet below:
# Load version control information
autoload -Uz vcs_info
precmd() { vcs_info }
# Format the vcs_info_msg_0_ variable
zstyle ':vcs_info:git:*' formats '%b'
# Determine if current working directory is a git repository
git_branch_color() {
if current_git_status=$(git status 2> /dev/null); then
parse_git_dirty
else
echo ""
fi
}
# Change branch color if working tree is clean
parse_git_dirty() {
if current_git_status=$(git status | grep 'Changes to be committed:\|Untracked files:\|modified:|deleted:' 2> /dev/null); then
echo "%F{red}"
else
echo "%F{green}"
fi
}
# Set up the prompt (with git branch name)
setopt PROMPT_SUBST
PROMPT='%F{white}%d $(git_branch_color)${vcs_info_msg_0_} %f$'
Using the rubric below, assess how you did with these exercises. These are the same metrics your instructors will use to determine if you are prepared for Mod 1!
- I read carefully read ALL directions
- I completed all parts of the exercises (not including Extensions) to the best of my ability
- I used correct syntax, spacing and naming conventions
- I followed ALL formatting instructions
- I pushed myself out of my comfort zone and experimented/broke things to try to learn
- I spent no longer than 20-30 mins Googling a specific problem before asking for help
- I went back to the lesson to search for clarification before asking for help
Are you stuck on something? Here is the BEST way to ask for help:
- Find the
Session 2 HW Thread
in your Mod 0 Slack channel - Start or reply in the thread with the problem you are facing. Be sure to follow the guidelines for asking questions below:
- I can explain what I am trying to do or accomplish
- I can what I have tried so far and/or what resources I've tried online
- I can describe specifically what I am stuck on
- I provided screenshots and/or code examples to give context
- If I provided short code examples, I used
inline code formatting
for single lines of code/error messages - If I provided larger blocks of code, I used a code snippet in the correct format (such as
.js
or.rb
)
- If I provided short code examples, I used
- Usually, your classmates will be able to answer your question or point you in the right direction very quickly! If not, an instructor will reply within 24-48 hours
-
This course is how I personally learned command line. If time permits, I highly recommend reading and practicing.
-
Also recommended by Jeff Casimir: Michael Hartl's Learn Enough Command Line.
🦀