Editing and branching in the browser
Last updated
Lola Remy spots a mistake in the adobo, and Ana is on her phone. She can fix it on GitHub without a computer. In this lesson you'll edit and commit on the website, make and compare branches there, and publish a release. Every button makes the same Git commits and branches you made in Stages 1 to 3.
By the end of this lesson you can
- Create and edit files on GitHub, and commit with a good message
- Make, switch, compare and delete branches on the website
- Publish a release: a tag with notes
Edit and commit
Open a file and press the pencil (lesson 4.1, step 5). The file opens in an editor with Edit and Preview tabs. Make the change, then press Commit changes…:
- Your change. What you changed, as a diff: red for the old line, green for the new.
- Message. The commit message, with an optional longer description: the same as the subject and body in lesson 1.7.
- Which branch. Straight onto the branch you’re on, or onto a new branch, ready for a pull request (Stage 5).
- Commit changes. Makes one commit on GitHub. Your computer’s copy doesn’t have it until you pull (lesson 4.6).
Add file › Create new file works the same way. Typing a / in the file name makes a folder: desserts/turon.md. Files can also be renamed (edit the name) and deleted (the … menu), each as a commit.
GitHub suggests a message such as "Update adobo.md". It names the file, not the change. Rewrite these three, made on GitHub from Ana's phone:
GitHub suggested:
Update adobo.mdWhat the commit really did: Changed the salt from 1 tsp to 2 tsp, as Lola Remy says.
0/50GitHub suggested:
Create turon.mdWhat the commit really did: Added Lola Remy’s turon recipe in a new desserts folder.
0/50GitHub suggested:
Delete notes.txtWhat the commit really did: Removed a file of old shopping notes that was uploaded by mistake.
0/50
For bigger edits, pressing . on a repository page opens github.dev, a fuller editor in the browser that can change several files in one commit.
Branches on the website
The branch menu (the button saying main) lists the branches. To make one, type a new name into its search box and choose Create branch: desserts from main.
- Search box. Type to find a branch, or a new name to make one.
- Branches. Every branch on GitHub. The tick is the one you’re looking at; default is the one people see first, usually main.
- Create branch. Makes the branch at main’s newest commit, like
git branch desserts(lesson 3.2). It exists on GitHub only until you fetch it. - View all branches. The branches page: when each was last changed, and a bin to delete one. A deleted branch can be restored from there for a while.
With desserts chosen in the menu, the files shown and every edit you commit belong to that branch. main doesn't change until the branch is merged, which on GitHub is done with a pull request (lesson 5.2).
Comparing branches
To see what a branch has that main doesn't, add /compare to the repository's address, or open Pull requests › New pull request, and choose the two branches. GitHub shows the commits and the diff between them, the same as git log main..desserts and git diff main...desserts would.
Seeing a comparison doesn't change anything. Turning it into a pull request is Stage 5.
Releases
A release is GitHub's page for a version: a tag (lesson 3.6) plus notes written in Markdown, and optional files to download. Releases › Draft a new release lets you pick or make a tag, write the notes, and publish. Generate release notes writes a first draft from the merged pull requests.
- Version and Latest. The release’s title. Latest marks the newest.
- Tag and commit. The tag this release is made from, and its commit’s short hash.
- Immutable. This release has been locked, so its tag and files can’t be changed after publishing.
- Notes. What changed, grouped into features, fixes and other changes, each linked to its pull request.
- Tags. Every tag in the repository, with or without a release.
Kusina's first release, at the end of the capstone, will be v1.0: twenty recipes, with notes saying which ones.
Spot the trap: the default message
Ana fixes eleven typos over a week, each from her phone. GitHub fills in “Update adobo.md”, “Update sinigang.md”, “Update adobo.md”… and she presses Commit each time.
What happens if…
Check what you learned
Sources
Every command on this page behaves as these pages describe, and the sandbox prints what Git 2.55 prints. Hosting features (pull requests, protected branches) come from the host’s own documentation.
- GitHub Docs: Editing files: the web editor and its commit form
- GitHub Docs: Creating and deleting branches within your repository: the branch menu
- GitHub Docs: Viewing branches in your repository: the branches page
- GitHub Docs: About releases: tags, notes and files
- GitHub Docs: Basic writing and formatting syntax: the Markdown GitHub shows in files, issues and release notes