Git and Source Control
Using Git in Codevre, from the terminal or the Source Control panel, including how Nodepod's Git differs from standard Git.
On this page
One Git, two ways in
Link to “One Git, two ways in”Git in Codevre is Nodepod's built-in Git. You can use it:
- in the terminal:
git init,git add,git commit,git status,git log,git checkout -b,git clone,git pull,git pushand so on - in the Source Control panel (Ctrl+Shift+G), which runs those same
gitcommands for you
Because the panel runs real git commands, the terminal and the panel always agree. The editor reads the repository directly to draw file markers and Git diffs.
.git is saved with your project, so history, branches and the remote come back when you reopen it.
The Source Control panel
Link to “The Source Control panel”No repository yet:
- Initialize Repository runs
git init. - Publish to GitHub creates a GitHub repository and pushes the project. See GitHub.
With a repository, from top to bottom:
- Branch switcher. Switch branches or Create new branch…. A link to the GitHub remote appears next to it.
- Message box and Commit (or Ctrl+Enter). With nothing staged, Commit All offers to stage everything and commit.
- Publish Branch / Sync Changes. Appears when the branch isn't on GitHub yet or you're ahead or behind.
↓means GitHub has new commits;↑3means three commits to push. - Merge Changes: files with conflicts (during a merge).
- Staged Changes: with Unstage (−) per file or for all.
- Changes: with Stage (+) and Discard (↶) per file or for all. Discarding an untracked file deletes it. Discarding is permanent.
- Commits: recent history with message, short hash and age.
Click a changed file to see its diff. The ⋯ menu has Pull, Push, Sync, Fetch, Abort Merge, Create Branch, Switch Branch, Stage/Unstage/Discard All and Connect/Disconnect GitHub.
The panel's commit author comes from your Codevre account name and email, unless the repository has its own user.name and user.email.
Markers in the editor
Link to “Markers in the editor”| Letter | Meaning |
|---|---|
| U | Untracked: new and not git add-ed |
| A | Added: a staged new file |
| M | Modified, staged or not |
| D | Deleted |
| C | Conflict left by a merge |
They appear in the Explorer, on tabs and in the editor gutter. The Diff toggle compares a file with the last commit. See The editor.
Pull, push and sync
Link to “Pull, push and sync”Talking to GitHub (clone of private repos, fetch, pull, push) needs GitHub connected. See GitHub. Public repositories can be cloned without it.
- Pull fetches and merges, like real Git. If you have nothing GitHub lacks, it fast-forwards. Otherwise it does a line-level three-way merge. Uncommitted edits are kept unless GitHub changed the same file.
- Push sends your commits. If GitHub has commits you don't, the push is rejected and you're offered Force Push. Force Push only happens after you confirm.
- Sync fetches, pulls if GitHub is ahead, then pushes what you have, including a merge commit.
If a pull would overwrite uncommitted changes, Codevre stops and lists the files. You can cancel, commit or discard, and pull again; or choose Pull and Overwrite, which replaces every changed file with GitHub's version. New files you created are kept. If the histories are unrelated (the GitHub repo was created separately), you're asked before the project is replaced with GitHub's version.
Merges and conflicts
Link to “Merges and conflicts”When both sides changed the same lines, the merge stops and the files appear under Merge Changes:
- Open the file and pick Accept Current, Accept Incoming or Accept Both above each conflict, or use the row buttons to take a whole side ("mine" or "GitHub's").
- Stage the file (+) to mark it resolved. If it still contains
<<<<<<<markers you're warned first. - Commit to finish the merge. The merge message is pre-filled.
Abort (or git merge --abort) puts the merged files back as they were before the pull.
While a merge is in progress you can't switch branches or sync.
How Nodepod's Git differs
Link to “How Nodepod's Git differs”Nodepod implements Git in JavaScript. It's compatible with GitHub, but it isn't the standard git binary:
- No
.gitignoresupport. Only.git,node_modulesand.cacheare skipped.git add -Astages everything else, including build output, so stage selectively or delete what you don't want committed. - Its own storage format. Objects live in
.git/objects/store.json, and the index is JSON. A.gitfolder from Codevre can't be used by desktop Git, and vice versa. To move a project between them, push to GitHub and clone. - Push and pull use the GitHub REST API, not the Git network protocol. Only GitHub remotes are supported for authenticated operations.
- Pushing creates new commit hashes. Codevre pushes by building commits through GitHub's API, so the hash on GitHub differs from the local one. Codevre records the mapping in
.git/codevre-sync.jsonso "ahead" and "behind" stay correct. If a branch was pushed from somewhere else first, the first push may need a force push. After that the histories line up. checkoutandswitchoverwrite files without checking. The panel asks before switching with uncommitted changes. In the terminal, commit or stash first.- Codevre's version of Nodepod adds UTF-8 and binary-safe clone, push and pull; push that rejects non-fast-forward updates; and pull that refuses to clobber local changes or diverged history unless
--forceis given.
Troubleshooting
Link to “Troubleshooting”- Every file shows A after opening a project. The commit object couldn't be read yet. Codevre retries automatically; click Refresh in the panel if it persists.
- Sync keeps showing ↑1. Click Refresh, which also fetches. If the branch was pushed from another device first, a one-time Force Push lines the histories up.
- "Connect GitHub to push to GitHub." Connect GitHub from the panel or the terminal. See GitHub.
- To report a problem, run
await __scm.diagnose()orawait __git.debugState()in the browser console and include the output.