Let’s practice using Git from the command line.
Create 🍒🍎🍌🍇🍑🍉🍍 basket
cd ~/Development/
mkdir fruit-basket
cd fruit-basket
echo "i am cherry" > cherries.txt
echo "i am a strawberry" > strawberries.txt
echo "i am a watermelon" > watermelons.txt
Initialize repository
git init
git status
git log
Add the fruits to the staging area.
git add cherries.txt
git add strawberries.txt
git add watermelons.txt
git status
git log
Create a commit.
git commit -m "add cherries, strawberries, and watermelons"
git status
git log
Create a blank github repo called “fruit-basket”.
Set your remotes (follow the instructions in the new github repository, it should look something like below).
git remote add origin git@github.com:XXXXX/XXXXX.git
git push --set-upstream origin master
Push the commit.
git push
git status
git log
~/Development/universe
pwd
and ls
to remind yourself where you are and what is theredouble check to make sure there are no untracked changes, or tracked changes in the “staging area” that haven’t been committed yet. Take a look at the commit log. Build a mental model of what your repository looks like. Then, run a git pull just in case, to grab any new changes from GitHub that you’re missing.
git status
git log
git pull
open mars.txt
in sublime text and add a new fact to it about mars and save the file
add that change to the staging area. But first, glance at your staging area (git status
) and your commit log (git log
) to update your mental model
git status
git log
git add solar_system/planets/mars.txt
Glance at your staging area (git status
) and your commit log (git log
) again to update your mental model. Now commit those changes.
git status
git log
git commit -m "add mars"
push your commit
git push
and check your repository online by refereshing the page in github
Repeat the steps above 3 times, each time for a different planet
bonus
Try making a commit that involves changing multiple files (do two planets in the same commit)