AI Hints
Home›Git & GitHub Tutorial›Files In and Out
Git & GitHub · Lesson 21 of 144

Practice: A Tiny Project

Your first full history.

⏱ 2 min read▶ Video at 21:21🎓 Free
Watch this lesson in the Git & GitHub courseWatch on YouTube ↗Full Git & GitHub course

Time to put it all together. Pause the video, open your terminal, and try this on your own. Make a folder called recipes. Turn it into a repository. Create a file called pancakes dot TXT, with one line. Then commit it, with a good message.

Practice: A Tiny Project
From the video: Practice: A Tiny Project
  • Make a folder: recipes
  • git init
  • Create pancakes.txt and commit it

One solution

Here's one solution. Make the folder, move into it, and git init. Write a line into pancakes dot TXT. Check status. Add the file. Commit, with a message that starts with a verb. And finally, the log shows our first commit.

git
mkdir recipes
cd recipes
git init
Initialized empty Git repository in /Users/sam/projects/recipes/.git/
echo "Pancakes: flour, eggs, milk" > pancakes.txt
git status --short
?? pancakes.txt
git add pancakes.txt
git commit -m "Add pancake recipe"
[main (root-commit) 4eaba84] Add pancake recipe
 1 file changed, 1 insertion(+)
 create mode 100644 pancakes.txt
git log --oneline
4eaba84 (HEAD -> main) Add pancake recipe

Quick check

Quick check. You changed a file, and ran git add. Which command shows the change that's about to be committed? Plain git diff, git diff dash dash staged, or git log? The answer is git diff dash dash staged. Plain diff would show nothing, because the change is already staged.

Quick check
You changed a file and ran git add. Which shows the staged change?

Summary

You can now create a repository, stage, commit, and read your history. That's the core of Git. Next, a practice round, reading history like a detective.

Key takeaways
  • init, add, commit
  • status, log, diff
  • You know the basics
Next up: Practice: History Detective — reading a project's past