Module 3 · Git & GitHub: From First Commit to Pull Request
Working With a Team: Issues, Project Files and Keeping Secrets Safe
Use the rest of GitHub like a professional. Track work with issues, give a repository the files that make it look and feel professional, manage who can do what, and keep passwords and keys out of your history, including what to do when one gets in.
About 25 minutes
Repositories are also workplaces
GitHub is more than storage. Teams use it to plan work, discuss it, review it and release it. This lesson covers the tools around the code that make a repository professional.
Issues: tracking work and bugs
An issue is a page for one task, bug, question or idea. Every project, from a student's notebook to a company's product, uses them.
A good issue has:
- A clear title: "Contact form accepts an empty email", not "Bug".
- What happened and what you expected.
- Steps to reproduce, so someone else can see the problem themselves.
- Context: browser, device, screenshots, error messages.
You can organise issues with labels (bug, enhancement, good first issue, documentation), assignees (who is working on it) and milestones (a group of issues for one release). Each issue has a number, such as #12. In a commit message or pull request, Fixes #12 links the work to the issue and closes it when merged, as you saw in the last lesson.
GitHub Projects adds a board of cards in columns (To do, In progress, Done), a simple way to see who is doing what.
The files that make a repository professional
Open any well-run project, and you find the same few files near the top. Adding them takes minutes and makes the repository look cared for.
| File | What it is for |
|---|---|
README.md | The front page. What the project is, how to use it, how to run it |
LICENSE | Says what others may do with your code. Without one, nobody is legally allowed to reuse it. MIT is a popular, permissive choice |
.gitignore | Files to leave out (lesson 3) |
CONTRIBUTING.md | How to help: how to report bugs, how to submit a pull request |
CODE_OF_CONDUCT.md | How people are expected to behave |
.github/ folder | Templates for issues and pull requests, and automations (lesson 10) |
GitHub helps: when you create a repository, you can tick Add a README, choose a .gitignore template for your language, and pick a licence.
A README a newcomer can use
A great README answers, in order: What is this? Why should I care? How do I run it? How can I help?
# Kitchen Orders
A small web page where customers choose a meal and send an order on WhatsApp.
## Features
- Menu with prices in naira
- One-tap order message
## Run it
1. Download the project
2. Open `index.html` in your browser
## Contributing
Found a bug? Open an issue. Pull requests are welcome.
## Licence
MITWho can do what
For a repository on your account, you decide who may change it. Under Settings, then Collaborators, you can invite teammates. For organisations, there are roles: Read (view and comment), Triage, Write (push branches), Maintain and Admin. Give people the least access they need.
You can also protect main with branch protection rules: require a pull request, require approvals, require checks to pass, and block force pushes. This makes it impossible to push untested work straight to main, even by accident.
Keeping secrets out of Git
This is the most important security lesson in this course. A secret committed to Git is a secret you should consider leaked, even in a private repository, even if you delete the file later.
Secrets include passwords, API keys, tokens, database connection strings, private keys and .env files. Why it is so dangerous:
- Git remembers everything. Deleting the file in a new commit leaves it in the history, which anyone with access (or anyone, if public) can read.
- Bots scan GitHub constantly for keys. A leaked cloud key can be found and abused within minutes, and the bill lands on you.
Prevention
- Never write a secret directly into code. Keep them in a
.envfile (or environment variables) and ignore it in.gitignorefrom the very first commit. - Share an example file,
.env.example, with fake values, so teammates know what to fill in. - Check
git statusandgit diff --stagedbefore every commit. Make it a habit.
If a secret was committed: the steps, in order
- Revoke or rotate the secret immediately. Go to the service (GitHub, your cloud provider, your payment provider) and delete that key or password and create a new one. This is the step that actually protects you. Do it first.
- Stop tracking the file, so it stops appearing in future commits:
Shell (bash)
git rm --cached .env # remove it from Git, but keep the file on your computer
echo ".env" >> .gitignore # make sure it is ignored from now on
git add .gitignore
git commit -m "Stop tracking .env"- Understand that the old key is still in the history. If the repository is public, or others have cloned it, assume the key is known, and rely on step 1. Specialist tools such as
git filter-repocan rewrite history to remove a file, but that is advanced, and it never replaces rotating the key.
Try step 2 in the task below.
Keeping your account safe
- Turn on two-factor authentication (you did this in lesson 1).
- Use tokens or SSH keys, never your password, and give tokens the smallest permissions and a short expiry.
- GitHub has secret scanning and Dependabot alerts (warnings about outdated, vulnerable libraries). Turn them on for your repositories, in Settings, then Code security.
Try it
First, fix a classic mistake: a secret file was committed. Stop tracking it safely.
Task
8 minSomeone committed .env by mistake (it holds a secret key). In real life you would first rotate the key. Then make Git stop tracking .env without deleting the file, add it to .gitignore, and commit the fix.
Your repository is checked for
- You removed .env from Git with git rm --cached (so the file stays on your computer)
- .env is no longer tracked in the latest commit
- .env still exists in your folder
- A .gitignore that lists .env is committed
- .gitignore contains .env
- Everything is committed (clean)
- There are at least two commits
Files in your project folder
Type a command below and press Enter. Type help for the commands you can use. Press the up arrow to bring back an earlier command.
Now write a bug report as a good issue. The goal is that a developer could reproduce the problem without asking you a single question.
Task
10 minWrite a GitHub issue for a bug in an app you know (or invent one: for example, a cart that shows the wrong total). Put the title on the first line, then the sections ## What happened, ## What I expected, ## Steps to reproduce (at least three numbered steps) and ## Environment (device, browser or version).
Your work is checked for
- A specific title on the first line (at least 5 words)
- A ## What happened section
- A ## What I expected section
- A ## Steps to reproduce section with at least three numbered steps
- The steps heading is present
- An ## Environment section
Practice
You pushed an API key to a public repository by mistake. What is the very first thing you should do: rotate the key or delete the file? Type one.
Earn your badge
Take the module check
Questions on this module. Pass and you earn the GitHub Collaboration badge, free.
Create a free account to earn the badge