DaleSchool

Files and Commits

Beginner15min

Learning Objectives

  • Create and edit files on GitHub's web interface
  • Write meaningful commit messages
  • View changes in the commit history

Creating a New File

Create a file directly in your repository.

  1. On the repository page, click Add fileCreate new file
  2. Enter the file name: notes.md
  3. Write the content:
# Study Notes

## What I Learned Today

- Creating a GitHub repository
- Writing a README
- Committing files

## Up Next

- Branches
- Pull Requests
  1. In the Commit changes section below:
    • Commit message: docs: add study notes file
    • Select Commit directly to the main branch
  2. Click Commit new file

Editing a File

You can also edit existing files.

  1. Click the notes.md file
  2. Click the pencil icon
  3. Make your edits
  4. Save with Commit changes

Viewing Commit History

Every change is recorded. Take a look.

  1. On the repository main page, click the N commits link (above the file list)
  2. Click any commit to see what changed
Green lines (+): Added content
Red lines (-): Removed content

This is called a diff.

"Why?" — Why Good Commit Messages Matter

Commit messages are letters to your future self and your teammates. Six months later, when you search "why did I change this file?", the commit message has the answer.

Bad commit messages:

fix
asdf
update

Good commit messages:

docs: add installation instructions to README
fix: resolve login button click error
feat: add dark mode feature

Tips for writing commit messages:

  • Be clear about what you did (save "why" for the body if needed)
  • Start with a present-tense verb: "add", "fix", "remove"
  • Keep it concise (50 characters or fewer recommended)

Many teams use type prefixes like feat:, fix:, docs: (Conventional Commits). Consistency makes the history much easier to read.

Deep Dive

Deleting a File

You can delete files on the GitHub web interface:

  1. Open the file you want to delete
  2. Click ··· (More options) or the trash icon in the top-right
  3. Select Delete file
  4. Enter a commit message and commit

Deletions are recorded as commits too. You can restore a previous state from the history at any time.

Uploading Files

You can upload local files to GitHub without a terminal:

  1. Click Add fileUpload files
  2. Drag and drop files or click choose your files
  3. Write a commit message
  4. Click Commit changes

You can upload multiple files at once. However, you need to set up folder structures manually.

  1. Create a new notes.md file in your repository and write down what you learned today.
  2. Edit notes.md to create a second commit.
  3. Check the commit history and view the diff.

Q1. What is a commit?

  • A) Deleting a repository
  • B) Saving file changes and leaving a message describing them
  • C) Copying code from another repository
  • D) Sending a notification to teammates

Further Reading