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.
Use commands in your terminal to create the directories and files structured exactly how they appear in the image below.
When you're done, type history
to see your commands. Copy and paste the commands that were used to create the directory and files:
180 mkdir session_3_practice
181 cd session_3_practice
182 touch budget.csv
183 touch mentors.txt
184 mkdir notes
185 mkdir practice
186 cd notes
187 touch git_notes.txt
188 touch command_line_notes.txt
189 cd practice
190 cd ..
191 cd practice
192 touch git_practice.txt
193 mkdir projects
194 cd projects
195 touch game.js
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):
p/Users/mitchellstandley/git_homework main $git status
On branch main
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: quotes.txt
/Users/mitchellstandley/git_homework main $git commit
[main 2c913e5] add "quotes.txt"
1 file changed, 1 insertion(+)
/Users/mitchellstandley/git_homework main $git status
On branch main
nothing to commit, working tree clean
/Users/mitchellstandley/git_homework main $git log
commit 2c913e58dac08580b2fb482caf69de60bf3ad2e2 (HEAD -> main)
Author: Mitch Standley <[email protected]>
Date: Thu Feb 4 14:58:35 2021 -0600
add "quotes.txt"
commit 720bc9944d4c43c8b4fe74d5c537c03187409447
Author: Mitch Standley <[email protected]>
Date: Thu Feb 4 06:36:35 2021 -0600
add first commit
added my first commit
/Users/mitchellstandley/git_homework main $
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:
- total_sales (integer)
- total_taxes (integer)
- address (string)
- store_name (string)
- is_open (boolean)
- sells_booze (boolean)
- candy_inventory (array)
- soda_inventory (array) **EXTENSION**
Methods:
- close_store (updates the is_open attribute to false)
- update_total_sales (updates the total_sales attribute with new sales data)
- update_total_taxes (updates the total_taxes attribute with new tax data)
- change_store_name (updates store_name to current)
- loses_liquour_license (updates the sells_booze to false)
-
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 explain 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.
Refactoring complete. Still not seeing any comments from instructors. 🦀