Step 5

Add a new file, index.html to sleeptime-git folder with the following content:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>SleepTime App</title>
</head>
<body>
  
</body>
</html>

Stage this file and commit the changes:

git add index.html
git commit -m "Add boilerplate html"

Staging multiple files

Add two more files to the working directory, style.css and script.js, with no content (empty files).

Link to these files in index.html:

<link rel="stylesheet" href="style.css">
<script src="script.js"></script>

I want to add these two files, as well as the changes I've made to the index.html, through a single commit. However, style.css and script.js are not yet staged for changes. I must explicitly add them using the git add command.

One way to add multiple files is to list them one by one (space separated):

git add style.css script.js

Another way, which is commonly used, is to use the following command (wildcard notion):

git add .

The git add . will add all changed and untracked files to the staging area (to be committed). You must be careful with this command as it will add "all" files, including those you probably don't intend to include (such as system files) to your Git repository. To avoid this, we will supply a .gitignore file first.

gitignore

A .gitignore file specifies intentionally untracked files that Git should ignore.

Create a file named .gitignore in sleeptime-git folder (notice the leading dot). I am going to add the following content to this file

.DS_Store
__MACOSX

My computer is a MacBook; the Mac OS generates system files .DS_Store and __MACOSX which are typically hidden (so you will not see them by default but Git will see and track them unless you tell it not to).

You can use this online tool to generate gitignore for different operating systems, project environments, etc.

Let's commit the .gitignore to our repository:

git add .gitignore 
git commit -m "Add gitignore"

Now, add and commit the changes made to our project earlier!

git add .
git commit -m "Link to external CSS and script files"