Git & GitHub · Your First Repository

Editing and Uploading Files

You can change a repository from any browser. Every save on GitHub is a commit with a message.

Beginner 5 min Lesson 5 of 19Shows Git 2.47 and GitHub.com as of 2026. GitHub changes its layout from time to time; button names stay the same.
Before you start:Creating a Repository
0/19 in Git & GitHub
On this page · 5 min · Beginner

Learning objectives#

  • Create a new file on GitHub
  • Upload files from your computer
  • Edit a file and commit the change
  • Write a useful commit message

Explanation#

On the repository page, Add file ▾ offers Create new file and Upload files. Type a path with slashes (css/style.css) to create folders at the same time.

Upload files accepts drag-and-drop of files and whole folders, up to 25 MB each in the browser. Larger files need Git on your computer (and very large ones Git LFS).

To edit, open a file and click the pencil icon. When you click Commit changes…, GitHub asks for a commit message and whether to commit directly to main or create a new branch and start a pull request.

A good commit message says what the change does in the imperative mood, under about 50 characters: “Add contact section”, “Fix typo in README”. An optional description underneath can explain why.

Step-by-step screens#

Drawings of github.com, the Git installer, VS Code and a terminal. GitHub changes its layout from time to time; the button names stay the same. The red numbers match the numbered actions under each picture; names on your computer will differ.

Loading pictures…

Code example: Good and bad commit messages#

TextGood and bad commit messages Illustrative
✓ Add contact form to the home page
✓ Fix broken link to the CSS file
✓ Update README with setup steps


✗ update
✗ changes
✗ asdf
✗ Fixed stuff and also changed colours and added footer
Expected output
Good messages make the history readable months later: git log --oneline becomes a list of what changed and when.

This example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.

Step-by-step explanation#

  1. Start with a verb: Add, Fix, Update, Remove.
  2. Describe one change per commit.
  3. Keep the first line short.
  4. Use the description for the why.

Real-world use case#

A teacher fixes a typo in the course notes from a phone during a break — no laptop, no Git install, still a proper commit.

Common mistakes#

Uploading secrets

Passwords and API keys in a public repository are found by bots within minutes. Never upload .env files.

One giant upload

Uploading a whole project as one commit loses history. Use Git locally for real projects.

Best practices#

  • Small commits with clear messages
  • Never upload secrets
  • Use Git locally for bigger projects
  • Preview Markdown before committing

Remember this#

Add file → Create / Upload.

Pencil = edit.

Every save is a commit with a message.

Practice exercise#

Your task: Write a good commit message for adding a footer with your email address.

Show solution
Text Illustrative
Add footer with contact email

Mini quiz#

Editing and Uploading Files quizMultiple choice Question 1 of 1

Which commit message is best?

Score so far: 0/0

Want more? Practise all Git & GitHub MCQs · Git & GitHub interview questions

My notes#

Saved in this browser.

Progress is saved in this browser. Sign in to sync.