Code and repositories / Change code
Edit files in the browser
You see a typo in a README, or a project needs one more config file, and a clone for that is too much. On the pages of a repository, you can edit a file, make a new file, upload files and delete a file. Each change is one commit, and it is your push: the same checks hold as for git push, and CI runs for it.
6 min read
You need write access to the repository. Without it, the pencil of a file is off: point at it to see why, and click Fork this repository to make the change in your own fork. In an archived repository, nobody edits files, its owners too, and the pencil says that the repository is archived.
1. Edit a file
- Open the file on its page.
- Click the pencil (Edit this file) above the file. The editor opens with the text of the file.
- Change the text. A markdown file has a Preview tab, which shows the text as the file page does.
- Click Commit changes….
The editor keeps the line breaks of the file (\r\n or \n) and its last line as they were. You type with plain line breaks, and the commit writes the file with its own.

The pencil is off for a file that the browser cannot edit. Point at it to see why:
- A binary file, such as an image. You can upload a new version of it (step 4).
- A file of more than 1 MiB.
- A file stored with Git LFS, and a path that
.gitattributessends to Git LFS: Use git to change files stored with Git LFS. - A file that you look at on a tag or a commit, and not on a branch. Pick a branch in the branch picker first.
2. Commit the change
The Commit changes dialog opens.
- Check the Commit message. It starts as
Update <file>. Type your own to replace it. - Add an Extended description if the change needs one. It is the rest of the commit message.
- Pick where the commit goes:
- Commit directly to the branch: the branch moves to your commit.
- Create a new branch for this commit and start a pull request: type a name for the new branch, or keep the one that the dialog picked:
<your name>-patch-1, or the next number that no branch has.
- Click Commit changes, or Propose changes for a new branch.

When the commit went straight onto the branch, the page of the file opens, with your commit. When it went to a new branch, the form of a new pull request opens. Its title and its description come from your commit. Click Create pull request.
Note
A branch whose branch rule requires a pull request takes no commit straight onto it, and the dialog offers only a new branch. So does a release branch of a repository synced with GitHub: its changes go through a pull request.
3. Make a new file
- Open the folder where the file goes, or the code view of the repository.
- Click Add file, then Create new file.
- Type the name of the file. A name with slashes makes the folders too:
docs/guide.mdmakes the folderdocs. - Write the text, then click Commit changes… and commit as in step 2. The message starts as
Create <file>.
A name that a file or a folder already has is refused. Pick another name, or edit that file.

4. Upload files
- Open the folder where the files go, or the code view.
- Click Add file, then Upload files.
- Drop files on the page, or click Choose files. The list shows each file and its size. Click the X of a file to take it out.
- Click Commit changes… and commit as in step 2. The message starts as
Add files via upload.
All the files go in one commit. A file with the name of a file in the folder replaces it. One commit takes up to 1,000 files and 8 MiB in all. The page says so before it sends anything, when the files are more than that. Use git for larger files, and for files stored with Git LFS.
5. Delete a file
- Open the file on its page.
- Click ... next to the pencil, then Delete file.
- Commit as in step 2. The message starts as
Delete <file>.
The folder of the file opens after the commit.
When someone pushed while you edited
Your commit goes on the branch as it is when you commit:
- When someone pushed to the branch, but the file you changed is still as you read it, your commit goes on top of their commit.
- When the file changed since you opened it, nothing is written. The dialog says that the file changed, and your text stays in the editor. Copy it, open the file again, and make your change on the new version.
What the checks refuse
A commit in the browser passes every check that git push of the same commit passes. When a check refuses it, the dialog says why, and nothing is written:
- Branch rules: a rule that requires a pull request refuses a commit straight onto the branch.
- Push protection: a known secret format in a file or in the commit message, and a file such as
.env, when the repository blocks them. Remove the secret, or put the file in the vault. - Size: a repository at its size limit refuses a commit that adds data.
- Git LFS: a path that
.gitattributessends to Git LFS, and an LFS pointer file.
Change a file from the command line or an agent
You need no clone for one file either:
src repo write-file docs/guide.md
src repo write-file config.json --from ./new-config.json -m "Raise the timeout"
src repo delete-file old/notes.md
write-file writes the local file at the same path, or the file of --from (- reads standard input), to the default branch, or the branch of --branch. REST has GitHub's contents API, PUT and DELETE /api/v1/repos/{owner}/{repo}/contents/{path}, and MCP has create_or_update_file and delete_file. An agent writes only to its own branches and to the head of an open pull request, as with git push.
Done
You edit, make, upload and delete files on the pages of a repository. Each change is one commit, made as your push, straight onto the branch or onto a new branch with a pull request. A change that someone else made in the meantime is never lost: the commit waits until you read the new version.