Edit and commit
How your edits become drafts on GitDB, and how to stage and commit them from Source Control.
How editing works
Open any file from the GitDB Files view, edit it, and save it as usual. When you save, the extension stores the file's new content on GitDB as a draft.
- Drafts last. They're saved on GitDB under your account, so they survive restarting VS Code or your computer. You'll also see them when you connect from another computer with the same account.
- Drafts aren't commits. A draft doesn't become part of the repository until you commit it.
- Unsaved edits stay in the editor. Changes you haven't saved yet exist only in the VS Code editor, just like with any other file.
Your saved changes show up in several places:
- In the Source Control view, in the GitDB section. If you also have a local Git repository open, GitDB appears as a separate section.
- In the Files view, where changed files are labeled
(unstaged)or(staged). Deleted files add· deleted, and folders that exist only in your drafts show(new). - In the editor gutter, where change markers compare your draft with the committed version.
Create files and folders
- New file: click the New File icon in the Files view title bar, or right-click a folder and choose GitDB: New File. Type a name, which can include subfolders, such as
src/handler.ts. The extension creates an empty draft and opens it. - New folder: click the New Folder icon, or right-click and choose GitDB: New Folder. Git tracks files rather than folders, so the extension adds an empty
.gitkeepfile inside the new folder.
New files and folders are drafts until you commit them, just like edits.
Delete files and folders
Right-click a file or folder in the Files view, choose GitDB: Delete, and confirm. For a folder, the confirmation shows how many files will be deleted. The deletion shows up as a change in Source Control. Commit it to finish the deletion.
Review a change
Click a file in the Source Control view to open a diff. The left side is the committed version on the current branch, and the right side is your draft. Clicking a deleted file opens the committed version.
Stage and unstage
Source Control has two groups: Changes and Staged Changes.
- Click + next to a file under Changes to stage it.
- Click − next to a file under Staged Changes to unstage it.
- Click + or − on a group's header to stage or unstage everything in that group.
If you edit a file again after staging it, it moves back to Changes. Stage it again before you commit.
Commit
- Type a commit message in the Source Control message box, which shows Commit message (GitDB) when it's empty. A message is required.
- Click the ✓ (GitDB: Commit Staged Changes) in the Source Control title bar, or press Ctrl+Enter (Cmd+Enter on macOS) in the message box.
What gets committed:
- If you staged anything, only the staged changes are committed. Everything under Changes stays there for later.
- If nothing is staged, all your changes are committed.
- If you have no changes, you'll see Nothing to commit — there are no changes.
Everything included goes into a single commit. When it finishes, you'll see a confirmation like GitDB: Committed 3 file(s) — 1a2b3c4d.
Repositories that sync with GitHub
If your repository syncs with GitHub, your commit may be pushed to a GitHub work branch instead of the branch you're on. When that happens, the confirmation names the work branch: pushed to GitHub work-branch 'name'. Open a pull request on GitHub to merge it. Then open a pull request on GitHub to merge the work branch.
Switching branches with pending changes
Switching branches doesn't set your pending changes aside. They stay in Source Control, and they're committed to whichever branch is current when you commit. Finish and commit your work before you switch, or switch back first.
File size and binary files
- Each file's draft can be at most 1 MB. If you save a larger file, the save fails with an error saying the file exceeds the staging limit.
- The editor is for text files. Add large or binary files with git instead. See Create your first repository.
Limitations in version 0.1.5
- You can't discard changes. Once you save a change, it stays in Source Control until you commit it. Keep this in mind before you save edits you don't intend to commit.
- There's no merge-conflict view. See Merging.